# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
41713 | 2018-02-21T03:37:06 Z | adlet | Dango Maker (JOI18_dango_maker) | C++14 | 6 ms | 4520 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; #define int 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; } 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 - 2 >= 1 && 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]) { ++cnt; } else { ++m1; was[used[i][j]] = 1; g[used[i][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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4216 KB | Output is correct |
2 | Correct | 4 ms | 4320 KB | Output is correct |
3 | Correct | 4 ms | 4520 KB | Output is correct |
4 | Correct | 5 ms | 4520 KB | Output is correct |
5 | Correct | 6 ms | 4520 KB | Output is correct |
6 | Incorrect | 5 ms | 4520 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4216 KB | Output is correct |
2 | Correct | 4 ms | 4320 KB | Output is correct |
3 | Correct | 4 ms | 4520 KB | Output is correct |
4 | Correct | 5 ms | 4520 KB | Output is correct |
5 | Correct | 6 ms | 4520 KB | Output is correct |
6 | Incorrect | 5 ms | 4520 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4216 KB | Output is correct |
2 | Correct | 4 ms | 4320 KB | Output is correct |
3 | Correct | 4 ms | 4520 KB | Output is correct |
4 | Correct | 5 ms | 4520 KB | Output is correct |
5 | Correct | 6 ms | 4520 KB | Output is correct |
6 | Incorrect | 5 ms | 4520 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |