# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246205 | 2020-07-08T10:55:54 Z | Nightlight | Dango Maker (JOI18_dango_maker) | C++14 | 971 ms | 54008 KB |
#include <bits/stdc++.h> using namespace std; const int MAXP = 12005; int N, M; vector<int> adj[MAXP]; char A[3005][3005]; int id[3001][3001]; int match[MAXP]; bitset<MAXP> vis; int ans = 0; 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; } void maxmatch(int offset) { for(int i = 1, j = offset - 1; i <= offset; i++, j--) { if(i > N || j > M) continue; if(A[i][j] == 'R' && A[i + 1][j] == 'G' && A[i + 2][j] == 'W') { id[i][j] = ++p; id[i + 1][j] = p; id[i + 2][j] = p; } } for(int i = 1, j = offset - 1; i <= offset; i++, j--) { if(i > N || j > M) continue; if(A[i][j] == 'R' && A[i][j + 1] == 'G' && A[i][j + 2] == 'W') { p++; if(id[i][j]) edge(id[i][j], p); if(id[i][j + 1]) edge(id[i][j + 1], p); if(id[i][j + 2]) edge(id[i][j + 2], p); } } 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; } } } for(int i = 1; i <= p; i++) { adj[i].clear(); match[i] = 0; } ans += p - cnt; p = 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 = 2; i <= N + M; i++) maxmatch(i); printf("%d\n", ans); cin >> N; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 5 ms | 640 KB | Output is correct |
6 | Correct | 5 ms | 640 KB | Output is correct |
7 | Correct | 5 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 640 KB | Output is correct |
11 | Correct | 5 ms | 640 KB | Output is correct |
12 | Correct | 5 ms | 640 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
14 | Correct | 5 ms | 640 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 5 ms | 640 KB | Output is correct |
6 | Correct | 5 ms | 640 KB | Output is correct |
7 | Correct | 5 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 640 KB | Output is correct |
11 | Correct | 5 ms | 640 KB | Output is correct |
12 | Correct | 5 ms | 640 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
14 | Correct | 5 ms | 640 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 640 KB | Output is correct |
17 | Correct | 5 ms | 640 KB | Output is correct |
18 | Correct | 5 ms | 640 KB | Output is correct |
19 | Correct | 5 ms | 640 KB | Output is correct |
20 | Correct | 5 ms | 692 KB | Output is correct |
21 | Correct | 5 ms | 768 KB | Output is correct |
22 | Correct | 5 ms | 640 KB | Output is correct |
23 | Correct | 5 ms | 640 KB | Output is correct |
24 | Correct | 5 ms | 640 KB | Output is correct |
25 | Correct | 5 ms | 640 KB | Output is correct |
26 | Correct | 5 ms | 640 KB | Output is correct |
27 | Correct | 5 ms | 640 KB | Output is correct |
28 | Correct | 5 ms | 640 KB | Output is correct |
29 | Correct | 5 ms | 640 KB | Output is correct |
30 | Correct | 5 ms | 640 KB | Output is correct |
31 | Correct | 5 ms | 768 KB | Output is correct |
32 | Correct | 5 ms | 640 KB | Output is correct |
33 | Correct | 5 ms | 640 KB | Output is correct |
34 | Correct | 5 ms | 640 KB | Output is correct |
35 | Correct | 5 ms | 640 KB | Output is correct |
36 | Correct | 5 ms | 768 KB | Output is correct |
37 | Correct | 5 ms | 640 KB | Output is correct |
38 | Correct | 5 ms | 640 KB | Output is correct |
39 | Correct | 5 ms | 640 KB | Output is correct |
40 | Correct | 5 ms | 768 KB | Output is correct |
41 | Correct | 5 ms | 768 KB | Output is correct |
42 | Correct | 5 ms | 640 KB | Output is correct |
43 | Correct | 5 ms | 640 KB | Output is correct |
44 | Correct | 5 ms | 640 KB | Output is correct |
45 | Correct | 5 ms | 640 KB | Output is correct |
46 | Correct | 5 ms | 640 KB | Output is correct |
47 | Correct | 5 ms | 640 KB | Output is correct |
48 | Correct | 5 ms | 768 KB | Output is correct |
49 | Correct | 5 ms | 640 KB | Output is correct |
50 | Correct | 5 ms | 768 KB | Output is correct |
51 | Correct | 5 ms | 768 KB | Output is correct |
52 | Correct | 5 ms | 640 KB | Output is correct |
53 | Correct | 5 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 640 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 5 ms | 640 KB | Output is correct |
6 | Correct | 5 ms | 640 KB | Output is correct |
7 | Correct | 5 ms | 640 KB | Output is correct |
8 | Correct | 5 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 640 KB | Output is correct |
11 | Correct | 5 ms | 640 KB | Output is correct |
12 | Correct | 5 ms | 640 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
14 | Correct | 5 ms | 640 KB | Output is correct |
15 | Correct | 5 ms | 640 KB | Output is correct |
16 | Correct | 5 ms | 640 KB | Output is correct |
17 | Correct | 5 ms | 640 KB | Output is correct |
18 | Correct | 5 ms | 640 KB | Output is correct |
19 | Correct | 5 ms | 640 KB | Output is correct |
20 | Correct | 5 ms | 692 KB | Output is correct |
21 | Correct | 5 ms | 768 KB | Output is correct |
22 | Correct | 5 ms | 640 KB | Output is correct |
23 | Correct | 5 ms | 640 KB | Output is correct |
24 | Correct | 5 ms | 640 KB | Output is correct |
25 | Correct | 5 ms | 640 KB | Output is correct |
26 | Correct | 5 ms | 640 KB | Output is correct |
27 | Correct | 5 ms | 640 KB | Output is correct |
28 | Correct | 5 ms | 640 KB | Output is correct |
29 | Correct | 5 ms | 640 KB | Output is correct |
30 | Correct | 5 ms | 640 KB | Output is correct |
31 | Correct | 5 ms | 768 KB | Output is correct |
32 | Correct | 5 ms | 640 KB | Output is correct |
33 | Correct | 5 ms | 640 KB | Output is correct |
34 | Correct | 5 ms | 640 KB | Output is correct |
35 | Correct | 5 ms | 640 KB | Output is correct |
36 | Correct | 5 ms | 768 KB | Output is correct |
37 | Correct | 5 ms | 640 KB | Output is correct |
38 | Correct | 5 ms | 640 KB | Output is correct |
39 | Correct | 5 ms | 640 KB | Output is correct |
40 | Correct | 5 ms | 768 KB | Output is correct |
41 | Correct | 5 ms | 768 KB | Output is correct |
42 | Correct | 5 ms | 640 KB | Output is correct |
43 | Correct | 5 ms | 640 KB | Output is correct |
44 | Correct | 5 ms | 640 KB | Output is correct |
45 | Correct | 5 ms | 640 KB | Output is correct |
46 | Correct | 5 ms | 640 KB | Output is correct |
47 | Correct | 5 ms | 640 KB | Output is correct |
48 | Correct | 5 ms | 768 KB | Output is correct |
49 | Correct | 5 ms | 640 KB | Output is correct |
50 | Correct | 5 ms | 768 KB | Output is correct |
51 | Correct | 5 ms | 768 KB | Output is correct |
52 | Correct | 5 ms | 640 KB | Output is correct |
53 | Correct | 5 ms | 640 KB | Output is correct |
54 | Correct | 10 ms | 640 KB | Output is correct |
55 | Correct | 25 ms | 10744 KB | Output is correct |
56 | Correct | 19 ms | 768 KB | Output is correct |
57 | Correct | 18 ms | 14208 KB | Output is correct |
58 | Correct | 100 ms | 12380 KB | Output is correct |
59 | Correct | 809 ms | 45868 KB | Output is correct |
60 | Correct | 817 ms | 45764 KB | Output is correct |
61 | Correct | 792 ms | 45620 KB | Output is correct |
62 | Correct | 11 ms | 640 KB | Output is correct |
63 | Correct | 752 ms | 45552 KB | Output is correct |
64 | Correct | 940 ms | 46076 KB | Output is correct |
65 | Correct | 962 ms | 54008 KB | Output is correct |
66 | Correct | 971 ms | 53880 KB | Output is correct |
67 | Correct | 855 ms | 53472 KB | Output is correct |
68 | Correct | 843 ms | 53496 KB | Output is correct |
69 | Correct | 845 ms | 53568 KB | Output is correct |
70 | Correct | 102 ms | 12536 KB | Output is correct |
71 | Correct | 102 ms | 12536 KB | Output is correct |
72 | Correct | 101 ms | 12536 KB | Output is correct |
73 | Correct | 105 ms | 12540 KB | Output is correct |
74 | Correct | 102 ms | 12536 KB | Output is correct |
75 | Correct | 111 ms | 12536 KB | Output is correct |
76 | Correct | 101 ms | 12536 KB | Output is correct |
77 | Correct | 102 ms | 12536 KB | Output is correct |
78 | Correct | 106 ms | 12536 KB | Output is correct |
79 | Correct | 102 ms | 12540 KB | Output is correct |
80 | Correct | 103 ms | 12536 KB | Output is correct |
81 | Correct | 106 ms | 12540 KB | Output is correct |
82 | Correct | 101 ms | 12588 KB | Output is correct |
83 | Correct | 104 ms | 12728 KB | Output is correct |
84 | Correct | 107 ms | 12536 KB | Output is correct |
85 | Correct | 104 ms | 12664 KB | Output is correct |
86 | Correct | 103 ms | 12536 KB | Output is correct |
87 | Correct | 103 ms | 12668 KB | Output is correct |
88 | Correct | 106 ms | 12536 KB | Output is correct |
89 | Correct | 103 ms | 12664 KB | Output is correct |
90 | Correct | 101 ms | 12540 KB | Output is correct |