제출 #464452

#제출 시각아이디문제언어결과실행 시간메모리
464452AdamGSGame (eJOI20_game)C++14
20 / 100
1 ms352 KiB
#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'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...