Submission #246152

#TimeUsernameProblemLanguageResultExecution timeMemory
246152NightlightDango Maker (JOI18_dango_maker)C++14
33 / 100
1375 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int N, M; vector<int> adj[3000001]; char A[3001][3001]; int id[3001][3001][2]; int match[3000001]; bitset<3000001> vis; int p; void edge(int u, int v) { // cout << u << " " << v << "\n"; adj[u].emplace_back(v); adj[v].emplace_back(u); } int kuhn(int u) { if(vis[u]) return 0; vis[u] = 1; for(int v : adj[u]) { if(match[v] == 0 || kuhn(match[v])) { match[u] = v; match[v] = u; return 1; } } return 0; } int main() { scanf("%d %d", &N, &M); for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { scanf(" %c", &A[i][j]); } } for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { if(A[i][j] == 'G') { if(A[i - 1][j] == 'R' && A[i + 1][j] == 'W') { id[i - 1][j][0] = ++p; id[i][j][0] = p; id[i + 1][j][0] = p; } if(A[i][j - 1] == 'R' && A[i][j + 1] == 'W') { id[i][j - 1][1] = ++p; id[i][j][1] = p; id[i][j + 1][1] = p; } } } } for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { if(id[i][j][0] && id[i][j][1]) edge(id[i][j][0], id[i][j][1]); } } bool ok = 0; int cnt = 0; while(ok == 0) { ok = 1; vis = 0; for(int i = 1; i <= p; i++) { if(match[i] == 0 && kuhn(i)) { cnt++; ok = 0; } } } printf("%d\n", p - cnt); // cin >> N; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &N, &M);
   ~~~~~^~~~~~~~~~~~~~~~~
dango_maker.cpp:35:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf(" %c", &A[i][j]);
       ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...