Submission #34543


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <queue>

#define rep2(i, b, n) for(int i=b; i < n; ++i)
#define rep(i, n) rep2(i, 0, n)
#define sz(v) v.size()
#define mk(x, y) make_pair(x, y)
#define fst first
#define scd second
#define X fst
#define Y scd
#define MEMSET(x, n) memset(x, n, sizeof(x))
#define MEMZERO(x) MEMSET(x, 0)
#define URU(y) (!(y % 4) && y % 100 || !(y % 400))

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

string s[1001];

int dx[] = { 0, 0, -1, 1, -1, -1, 1, 1 };
int dy[] = { -1, 1, 0, 0, -1, 1, -1, 1 };

bool check( int n )
{
	int i = sqrt((double)n);
	return (i*i == n);
}

int main( void )
{
	int h, w;
	while(cin >> h >> w) {
		rep(i, h) cin >> s[i];
		int a, b, c;
		a = b = c = 0;
		rep(y, h) rep(x, w) {
			if(s[y][x] == 'o') {
				queue<pii> q;
				q.push(mk(x, y));
				s[y][x] = '.';
				int cnt = 0;
				while(!q.empty()) {
					pii p = q.front(); q.pop();
					++cnt;
					rep(d, 8) {
						int xx = p.X + dx[d], yy = p.Y + dy[d];
						if(0 <= xx && xx < w && 0 <= yy && yy < h
							&& s[yy][xx] == 'o'
						) {
							s[yy][xx] = '.';
							q.push(mk(xx, yy));
						}
					}
				}
				if(cnt % 12 == 0 && check(cnt / 12))
					++a;
				else if(cnt % 11 == 0 && check(cnt / 11))
					++c;
				else
					++b;
			}
		}
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task D - アルファベット探し
User kkk
Language C++ (G++ 4.6.4)
Score 100
Code Size 1534 Byte
Status AC
Exec Time 95 ms
Memory 1804 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 58
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 23 ms 776 KB
00_sample_01.txt AC 23 ms 788 KB
00_sample_02.txt AC 22 ms 768 KB
00_sample_03.txt AC 22 ms 784 KB
00_sample_04.txt AC 22 ms 780 KB
00_sample_05.txt AC 22 ms 772 KB
01_rndsmall_00.txt AC 22 ms 768 KB
01_rndsmall_01.txt AC 23 ms 772 KB
01_rndsmall_02.txt AC 24 ms 848 KB
01_rndsmall_03.txt AC 22 ms 764 KB
01_rndsmall_04.txt AC 22 ms 776 KB
01_rndsmall_05.txt AC 22 ms 768 KB
01_rndsmall_06.txt AC 22 ms 764 KB
01_rndsmall_07.txt AC 22 ms 784 KB
01_rndsmall_08.txt AC 22 ms 772 KB
01_rndsmall_09.txt AC 22 ms 780 KB
01_rndsmall_10.txt AC 22 ms 784 KB
01_rndsmall_11.txt AC 24 ms 780 KB
01_rndsmall_12.txt AC 24 ms 776 KB
01_rndsmall_13.txt AC 22 ms 780 KB
01_rndsmall_14.txt AC 22 ms 780 KB
01_rndsmall_15.txt AC 22 ms 776 KB
01_rndsmall_16.txt AC 22 ms 780 KB
01_rndsmall_17.txt AC 25 ms 776 KB
01_rndsmall_18.txt AC 26 ms 784 KB
01_rndsmall_19.txt AC 20 ms 780 KB
02_rndmax_00.txt AC 78 ms 1792 KB
02_rndmax_01.txt AC 82 ms 1800 KB
02_rndmax_02.txt AC 89 ms 1796 KB
02_rndmax_03.txt AC 84 ms 1788 KB
02_rndmax_04.txt AC 87 ms 1796 KB
02_rndmax_05.txt AC 81 ms 1792 KB
02_rndmax_06.txt AC 85 ms 1796 KB
02_rndmax_07.txt AC 82 ms 1796 KB
02_rndmax_08.txt AC 82 ms 1796 KB
02_rndmax_09.txt AC 80 ms 1800 KB
02_rndmax_10.txt AC 80 ms 1804 KB
02_rndmax_11.txt AC 81 ms 1792 KB
02_rndmax_12.txt AC 94 ms 1792 KB
02_rndmax_13.txt AC 83 ms 1796 KB
02_rndmax_14.txt AC 89 ms 1788 KB
02_rndmax_15.txt AC 92 ms 1788 KB
02_rndmax_16.txt AC 84 ms 1796 KB
02_rndmax_17.txt AC 79 ms 1788 KB
02_rndmax_18.txt AC 80 ms 1792 KB
02_rndmax_19.txt AC 82 ms 1804 KB
03_rnd_00.txt AC 23 ms 780 KB
03_rnd_01.txt AC 35 ms 1156 KB
03_rnd_02.txt AC 36 ms 1028 KB
03_rnd_03.txt AC 37 ms 1028 KB
03_rnd_04.txt AC 39 ms 1024 KB
03_rnd_05.txt AC 25 ms 908 KB
03_rnd_06.txt AC 47 ms 1408 KB
03_rnd_07.txt AC 29 ms 1148 KB
03_rnd_08.txt AC 57 ms 1756 KB
03_rnd_09.txt AC 47 ms 1400 KB
04_empty_00.txt AC 74 ms 1796 KB
05_maxret_00.txt AC 95 ms 1792 KB