提出 #4840911


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/06  Problem: ARC 006 D / Link: http://arc006.contest.atcoder.jp/tasks/arc006_d  ----- */


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL H, W; cin >> H >> W;
	VS vs(H); FOR(i, 0, H) {
		cin >> vs[i];
	}

	const int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
	const int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
	auto is_in = [](int a, int b, int c) { return a <= b && b < c; };
	VVI used(H, VI(W, 0));
	auto f = [&](int Y, int X) {
		int res = 1;
		queue<PII>q;
		used[Y][X] = 1;
		q.push(PII(Y, X));
		while (!q.empty()) {
			int y, x; tie(y, x) = q.front(); q.pop();
			FOR(k, 0, 8) {
				int ny = y + DY[k], nx = x + DX[k];
				if (is_in(0, ny, H) && is_in(0, nx, W)) {
					if (!used[ny][nx] && vs[ny][nx] == 'o') {
						used[ny][nx] = 1;
						res++;
						q.push(PII(ny, nx));
					}
				}
			}
		}

		return res;
	};
	auto g = [](int n) {
		for (int i = 2; i*i <= n; i++) {
			int p2 = i * i;
			while (n%p2 == 0) {
				n /= p2;
			}
		}
		if (n == 3)return 0;
		if (n == 1)return 1;
		if (n == 11)return 2;
		assert(0);
	};
	VI ans(3, 0);
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			if (used[i][j] || vs[i][j] == '.')continue;
			int sz = f(i, j);
			int id = g(sz);
			ans[id]++;
		}
	}
	FOR(i, 0, 3) {
		cout << ans[i] << " \n"[i == 2];
	}


	return 0;
}

提出情報

提出日時
問題 D - アルファベット探し
ユーザ Yang33
言語 C++14 (GCC 5.4.1)
得点 100
コード長 2227 Byte
結果 AC
実行時間 20 ms
メモリ 5248 KiB

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 58
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_min.txt AC 1 ms 256 KiB
00_sample_01.txt AC 1 ms 256 KiB
00_sample_02.txt AC 1 ms 256 KiB
00_sample_03.txt AC 1 ms 256 KiB
00_sample_04.txt AC 1 ms 256 KiB
00_sample_05.txt AC 1 ms 256 KiB
01_rndsmall_00.txt AC 1 ms 384 KiB
01_rndsmall_01.txt AC 1 ms 384 KiB
01_rndsmall_02.txt AC 1 ms 384 KiB
01_rndsmall_03.txt AC 1 ms 384 KiB
01_rndsmall_04.txt AC 1 ms 384 KiB
01_rndsmall_05.txt AC 1 ms 384 KiB
01_rndsmall_06.txt AC 1 ms 384 KiB
01_rndsmall_07.txt AC 1 ms 384 KiB
01_rndsmall_08.txt AC 1 ms 384 KiB
01_rndsmall_09.txt AC 1 ms 384 KiB
01_rndsmall_10.txt AC 1 ms 384 KiB
01_rndsmall_11.txt AC 1 ms 384 KiB
01_rndsmall_12.txt AC 1 ms 384 KiB
01_rndsmall_13.txt AC 1 ms 384 KiB
01_rndsmall_14.txt AC 1 ms 384 KiB
01_rndsmall_15.txt AC 1 ms 384 KiB
01_rndsmall_16.txt AC 1 ms 384 KiB
01_rndsmall_17.txt AC 1 ms 384 KiB
01_rndsmall_18.txt AC 1 ms 384 KiB
01_rndsmall_19.txt AC 1 ms 384 KiB
02_rndmax_00.txt AC 10 ms 5248 KiB
02_rndmax_01.txt AC 12 ms 5248 KiB
02_rndmax_02.txt AC 15 ms 5248 KiB
02_rndmax_03.txt AC 12 ms 5248 KiB
02_rndmax_04.txt AC 14 ms 5248 KiB
02_rndmax_05.txt AC 13 ms 5248 KiB
02_rndmax_06.txt AC 14 ms 5248 KiB
02_rndmax_07.txt AC 11 ms 5248 KiB
02_rndmax_08.txt AC 12 ms 5248 KiB
02_rndmax_09.txt AC 10 ms 5248 KiB
02_rndmax_10.txt AC 11 ms 5248 KiB
02_rndmax_11.txt AC 12 ms 5248 KiB
02_rndmax_12.txt AC 11 ms 5248 KiB
02_rndmax_13.txt AC 12 ms 5248 KiB
02_rndmax_14.txt AC 15 ms 5248 KiB
02_rndmax_15.txt AC 14 ms 5248 KiB
02_rndmax_16.txt AC 12 ms 5248 KiB
02_rndmax_17.txt AC 10 ms 5248 KiB
02_rndmax_18.txt AC 11 ms 5248 KiB
02_rndmax_19.txt AC 12 ms 5248 KiB
03_rnd_00.txt AC 2 ms 384 KiB
03_rnd_01.txt AC 4 ms 1408 KiB
03_rnd_02.txt AC 4 ms 1280 KiB
03_rnd_03.txt AC 4 ms 1536 KiB
03_rnd_04.txt AC 4 ms 1664 KiB
03_rnd_05.txt AC 2 ms 512 KiB
03_rnd_06.txt AC 7 ms 2176 KiB
03_rnd_07.txt AC 3 ms 896 KiB
03_rnd_08.txt AC 7 ms 2944 KiB
03_rnd_09.txt AC 6 ms 2432 KiB
04_empty_00.txt AC 8 ms 5248 KiB
05_maxret_00.txt AC 20 ms 5248 KiB