Submission #1037194
Source Code Expand
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;
int h, w;
deque<deque<bool> > arrived;
vvi board;
vi dh = {-1, -1, -1, 0, 0, 1, 1, 1};
vi dw = {-1, 0, 1, -1, 1, -1, 0, 1};
// amount of cells, minimum of h, maximum of h
tuple<int, int, int> dfs(int ih, int jw) {
int num = 1;
int minh, maxh;
minh = maxh = ih;
queue<pii> st;
st.push(make_pair(ih, jw));
while (!st.empty()) {
auto cell = st.front();
st.pop();
int nexth, nextw;
rep (i, 8) {
nexth = cell.first;
nextw = cell.second;
nexth += dh[i];
nextw += dw[i];
if (arrived[nexth][nextw] || board[nexth][nextw] == 0) {
continue;
}
arrived[nexth][nextw] = true;
num += 1;
minh = min(minh, nexth);
maxh = max(maxh, nexth);
st.push(make_pair(nexth, nextw));
}
}
return make_tuple(num, minh, maxh);
}
int main() {
scanf("%d %d", &h, &w);
arrived.assign(h, deque<bool>(w, false));
board.assign(h, vi(w, 0));
rep (i, h) {
rep (j, w) {
char tmp;
scanf(" %c", &tmp);
if (tmp == 'o') {
board[i][j] = 1;
}
}
}
map<int, int> mp;
mp[12] = 0;
mp[16] = 1;
mp[11] = 2;
vi ans(3, 0);
rep (i, h) {
rep (j, w) {
if (arrived[i][j]) {
continue;
}
arrived[i][j] = true;
if (board[i][j] == 0) {
continue;
}
int num, minh, maxh;
tie(num, minh, maxh) = dfs(i, j);
int ratio = (maxh + 1 - minh) / 5;
ans[mp[num/(ratio * ratio)]] += 1;
}
}
printf("%d %d %d\n", ans[0], ans[1], ans[2]);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - アルファベット探し |
User |
tspcx |
Language |
C++11 (GCC 4.8.1) |
Score |
100 |
Code Size |
2592 Byte |
Status |
AC |
Exec Time |
103 ms |
Memory |
6044 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:79:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &h, &w);
^
./Main.cpp:85:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c", &tmp);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rndsmall_00.txt, 01_rndsmall_01.txt, 01_rndsmall_02.txt, 01_rndsmall_03.txt, 01_rndsmall_04.txt, 01_rndsmall_05.txt, 01_rndsmall_06.txt, 01_rndsmall_07.txt, 01_rndsmall_08.txt, 01_rndsmall_09.txt, 01_rndsmall_10.txt, 01_rndsmall_11.txt, 01_rndsmall_12.txt, 01_rndsmall_13.txt, 01_rndsmall_14.txt, 01_rndsmall_15.txt, 01_rndsmall_16.txt, 01_rndsmall_17.txt, 01_rndsmall_18.txt, 01_rndsmall_19.txt, 02_rndmax_00.txt, 02_rndmax_01.txt, 02_rndmax_02.txt, 02_rndmax_03.txt, 02_rndmax_04.txt, 02_rndmax_05.txt, 02_rndmax_06.txt, 02_rndmax_07.txt, 02_rndmax_08.txt, 02_rndmax_09.txt, 02_rndmax_10.txt, 02_rndmax_11.txt, 02_rndmax_12.txt, 02_rndmax_13.txt, 02_rndmax_14.txt, 02_rndmax_15.txt, 02_rndmax_16.txt, 02_rndmax_17.txt, 02_rndmax_18.txt, 02_rndmax_19.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt, 03_rnd_05.txt, 03_rnd_06.txt, 03_rnd_07.txt, 03_rnd_08.txt, 03_rnd_09.txt, 04_empty_00.txt, 05_maxret_00.txt |
Case Name |
Status |
Exec Time |
Memory |
00_min.txt |
AC |
19 ms |
924 KB |
00_sample_01.txt |
AC |
18 ms |
844 KB |
00_sample_02.txt |
AC |
19 ms |
796 KB |
00_sample_03.txt |
AC |
17 ms |
804 KB |
00_sample_04.txt |
AC |
18 ms |
928 KB |
00_sample_05.txt |
AC |
17 ms |
800 KB |
01_rndsmall_00.txt |
AC |
19 ms |
804 KB |
01_rndsmall_01.txt |
AC |
19 ms |
928 KB |
01_rndsmall_02.txt |
AC |
19 ms |
924 KB |
01_rndsmall_03.txt |
AC |
19 ms |
920 KB |
01_rndsmall_04.txt |
AC |
19 ms |
796 KB |
01_rndsmall_05.txt |
AC |
20 ms |
800 KB |
01_rndsmall_06.txt |
AC |
19 ms |
928 KB |
01_rndsmall_07.txt |
AC |
20 ms |
712 KB |
01_rndsmall_08.txt |
AC |
19 ms |
804 KB |
01_rndsmall_09.txt |
AC |
20 ms |
932 KB |
01_rndsmall_10.txt |
AC |
19 ms |
804 KB |
01_rndsmall_11.txt |
AC |
20 ms |
844 KB |
01_rndsmall_12.txt |
AC |
19 ms |
800 KB |
01_rndsmall_13.txt |
AC |
19 ms |
924 KB |
01_rndsmall_14.txt |
AC |
18 ms |
804 KB |
01_rndsmall_15.txt |
AC |
18 ms |
928 KB |
01_rndsmall_16.txt |
AC |
18 ms |
928 KB |
01_rndsmall_17.txt |
AC |
18 ms |
804 KB |
01_rndsmall_18.txt |
AC |
19 ms |
928 KB |
01_rndsmall_19.txt |
AC |
19 ms |
932 KB |
02_rndmax_00.txt |
AC |
86 ms |
5924 KB |
02_rndmax_01.txt |
AC |
90 ms |
5872 KB |
02_rndmax_02.txt |
AC |
95 ms |
5868 KB |
02_rndmax_03.txt |
AC |
92 ms |
5916 KB |
02_rndmax_04.txt |
AC |
94 ms |
5924 KB |
02_rndmax_05.txt |
AC |
92 ms |
5920 KB |
02_rndmax_06.txt |
AC |
95 ms |
6020 KB |
02_rndmax_07.txt |
AC |
90 ms |
5960 KB |
02_rndmax_08.txt |
AC |
89 ms |
5924 KB |
02_rndmax_09.txt |
AC |
88 ms |
5920 KB |
02_rndmax_10.txt |
AC |
88 ms |
5924 KB |
02_rndmax_11.txt |
AC |
90 ms |
5920 KB |
02_rndmax_12.txt |
AC |
89 ms |
6044 KB |
02_rndmax_13.txt |
AC |
92 ms |
5920 KB |
02_rndmax_14.txt |
AC |
97 ms |
5924 KB |
02_rndmax_15.txt |
AC |
94 ms |
5912 KB |
02_rndmax_16.txt |
AC |
90 ms |
5924 KB |
02_rndmax_17.txt |
AC |
88 ms |
6040 KB |
02_rndmax_18.txt |
AC |
88 ms |
5920 KB |
02_rndmax_19.txt |
AC |
88 ms |
5880 KB |
03_rnd_00.txt |
AC |
19 ms |
932 KB |
03_rnd_01.txt |
AC |
34 ms |
2212 KB |
03_rnd_02.txt |
AC |
35 ms |
1948 KB |
03_rnd_03.txt |
AC |
36 ms |
2124 KB |
03_rnd_04.txt |
AC |
40 ms |
2332 KB |
03_rnd_05.txt |
AC |
22 ms |
1056 KB |
03_rnd_06.txt |
AC |
48 ms |
2980 KB |
03_rnd_07.txt |
AC |
28 ms |
1568 KB |
03_rnd_08.txt |
AC |
56 ms |
4132 KB |
03_rnd_09.txt |
AC |
51 ms |
3100 KB |
04_empty_00.txt |
AC |
81 ms |
5872 KB |
05_maxret_00.txt |
AC |
103 ms |
5880 KB |