# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41715 | 2018-02-21T03:55:45 Z | adlet | Dango Maker (JOI18_dango_maker) | C++14 | 5 ms | 3640 KB |
#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; ++cnt; return true; } } 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] && used[i + 1][j] != used[i][j]) { was[used[i + 1][j]] = 1; g[used[i + 1][j]].push_back(n1 + m1); } if (used[i + 2][j] && used[i + 2][j] != used[i + 1][j] && used[i + 2][j] != used[i][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); } cout << cnt; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3448 KB | Output is correct |
2 | Correct | 4 ms | 3552 KB | Output is correct |
3 | Correct | 4 ms | 3552 KB | Output is correct |
4 | Correct | 4 ms | 3640 KB | Output is correct |
5 | Correct | 5 ms | 3640 KB | Output is correct |
6 | Incorrect | 4 ms | 3640 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3448 KB | Output is correct |
2 | Correct | 4 ms | 3552 KB | Output is correct |
3 | Correct | 4 ms | 3552 KB | Output is correct |
4 | Correct | 4 ms | 3640 KB | Output is correct |
5 | Correct | 5 ms | 3640 KB | Output is correct |
6 | Incorrect | 4 ms | 3640 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3448 KB | Output is correct |
2 | Correct | 4 ms | 3552 KB | Output is correct |
3 | Correct | 4 ms | 3552 KB | Output is correct |
4 | Correct | 4 ms | 3640 KB | Output is correct |
5 | Correct | 5 ms | 3640 KB | Output is correct |
6 | Incorrect | 4 ms | 3640 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |