답안 #464452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464452 2021-08-13T08:52:46 Z AdamGS Game (eJOI20_game) C++14
20 / 100
1 ms 352 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=30;
vector<pair<int,int>>V[LIM][LIM];
int odw[LIM][LIM], ile=0, kraw[LIM][LIM];
void DFS(int a, int b) {
	++ile;
	odw[a][b]=1;
	for(auto i : V[a][b]) if(!odw[i.st][i.nd]) DFS(i.st, i.nd);
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	rep(j, m) {
		if(s[j]=='0') {
			++kraw[0][j];
		}
	}
	rep(i, n-1) {
		cin >> s;
		rep(j, m) {
			if(s[j]=='0') {
				V[i][j].pb({i+1, j});
				V[i+1][j].pb({i, j});
				++kraw[i][j];
				++kraw[i+1][j];
			}
		}
	}
	cin >> s;
	rep(j, m) {
		if(s[j]=='0') {
			++kraw[n-1][j];
		}
	}
	rep(i, n) {
		cin >> s;
		if(s[0]=='0') {
			++kraw[i][0];
		}
		rep(j, m-1) {
			if(s[j+1]=='0') {
				V[i][j+1].pb({i, j});
				V[i][j].pb({i, j+1});
				++kraw[i][j];
				++kraw[i][j+1];
			}
		}
		if(s[m]=='0') {
			++kraw[i][m-1];
		}
	}
	vector<int>spojne;
	rep(i, n) rep(j, m) if(!odw[i][j] && kraw[i][j]==2) {
		ile=0;
		DFS(i, j);
		spojne.pb(ile);
	}
	cout << -spojne[0] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Incorrect 1 ms 332 KB Output isn't correct
14 Halted 0 ms 0 KB -