Submission #297951


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

int main() {
	const int H = 10, W = 10;
	char A[H][W+1];
	rep(i, H) scanf("%s", A[i]);
	bool ans = false;
	rep(y, H) rep(x, W) {
		char t = A[y][x];
		A[y][x] = 'o';
		UnionFind uf; uf.init(H * W);
		rep(i, H) rep(j, W) if(A[i][j] == 'o') {
			static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
			rep(d, 4) {
				int yy = i + dy[d], xx = j + dx[d];
				if(yy<0||yy>=H||xx<0||xx>=W) continue;
				if(A[yy][xx] == 'x') continue;
				uf.unionSet(i * W + j, yy * W + xx);
			}
		}
		int cc = 0;
		rep(i, H) rep(j, W) if(A[i][j] == 'o')
			cc += uf.root(i * W + j) == i * W + j;
		ans |= cc == 1;
		A[y][x] = t;
	}
	puts(ans ? "YES" : "NO");
	return 0;
}

Submission Info

Submission Time
Task B - 埋め立て
User anta
Language C++ (G++ 4.6.4)
Score 100
Code Size 2539 Byte
Status AC
Exec Time 24 ms
Memory 928 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:60:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 10_rand_00.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_11.txt, 10_rand_12.txt, 10_rand_13.txt, 10_rand_14.txt, 10_rand_15.txt, 10_rand_16.txt, 10_rand_17.txt, 10_rand_18.txt, 10_rand_19.txt, 10_rand_20.txt, 10_rand_21.txt, 10_rand_22.txt, 10_rand_23.txt, 10_rand_24.txt, 10_rand_25.txt, 10_rand_26.txt, 10_rand_27.txt, 10_rand_28.txt, 10_rand_29.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 22 ms 744 KB
00_sample_01.txt AC 23 ms 804 KB
00_sample_02.txt AC 21 ms 796 KB
10_rand_00.txt AC 23 ms 800 KB
10_rand_01.txt AC 21 ms 924 KB
10_rand_02.txt AC 23 ms 672 KB
10_rand_03.txt AC 22 ms 804 KB
10_rand_04.txt AC 21 ms 920 KB
10_rand_05.txt AC 23 ms 668 KB
10_rand_06.txt AC 22 ms 676 KB
10_rand_07.txt AC 23 ms 796 KB
10_rand_08.txt AC 23 ms 804 KB
10_rand_09.txt AC 22 ms 928 KB
10_rand_10.txt AC 21 ms 928 KB
10_rand_11.txt AC 23 ms 852 KB
10_rand_12.txt AC 22 ms 800 KB
10_rand_13.txt AC 22 ms 808 KB
10_rand_14.txt AC 24 ms 800 KB
10_rand_15.txt AC 23 ms 676 KB
10_rand_16.txt AC 21 ms 676 KB
10_rand_17.txt AC 22 ms 928 KB
10_rand_18.txt AC 22 ms 796 KB
10_rand_19.txt AC 24 ms 804 KB
10_rand_20.txt AC 22 ms 800 KB
10_rand_21.txt AC 22 ms 924 KB
10_rand_22.txt AC 23 ms 804 KB
10_rand_23.txt AC 23 ms 676 KB
10_rand_24.txt AC 22 ms 800 KB
10_rand_25.txt AC 22 ms 800 KB
10_rand_26.txt AC 22 ms 800 KB
10_rand_27.txt AC 22 ms 736 KB
10_rand_28.txt AC 22 ms 800 KB
10_rand_29.txt AC 24 ms 920 KB