Submission #41717

#TimeUsernameProblemLanguageResultExecution timeMemory
41717adletDango Maker (JOI18_dango_maker)C++14
13 / 100
5 ms3696 KiB
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("avx") #define name "name" #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout); typedef long long ll; const int N = 1e5; const int MN = 3e3 + 5; int n, m, n1, m1, cnt, timer; int used[MN][MN], was[N], mt[N]; char a[MN][MN]; vector < vector < int > > g(N); int dfs(int v, int p = -1) { if (was[v] == timer) return 0; was[v] = timer; for (int to : g[v]) { if (to == p) continue; if (mt[to] == -1 || dfs(mt[to], to)) { mt[to] = v; return 1; } } return 0; } int main() { file(name); cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> a[i][j]; if (j >= 3 && a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R') { ++n1; used[i][j] = n1; used[i][j - 1] = n1; used[i][j - 2] = n1; } } } for (int j = 1; j <= m; ++j) { for (int i = 1; i + 2 <= n; ++i) { if (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W') { if (!used[i][j] && !used[i + 1][j] && !used[i + 2][j]) { ++cnt; } else { ++m1; if (used[i][j]) { was[used[i][j]] = 1; g[used[i][j]].push_back(n1 + m1); } if (used[i + 1][j]) { was[used[i + 1][j]] = 1; g[used[i + 1][j]].push_back(n1 + m1); } if (used[i + 2][j]) { was[used[i + 2][j]] = 1; g[used[i + 2][j]].push_back(n1 + m1); } } } } } for (int i = 1; i <= n1; ++i) { if (!was[i]) { ++cnt; } } memset(was, 0, sizeof(was)); memset(mt, -1, sizeof(mt)); for (int i = 1; i <= n1; ++i) { ++timer; dfs(i); } for (int i = 1; i <= m1; ++i) { if (mt[n1 + i] != -1) ++cnt; } cout << cnt; }

Compilation message (stderr)

dango_maker.cpp:5:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
dango_maker.cpp:41:5: note: in expansion of macro 'file'
     file(name);
     ^
dango_maker.cpp:10:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file(s) if(fopen(s".in", "r")) freopen(s".in","r",stdin), freopen(s".out","w",stdout);
                                                                                              ^
dango_maker.cpp:41:5: note: in expansion of macro 'file'
     file(name);
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...