# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240274 | 2020-06-19T06:13:15 Z | MrRobot_28 | Planinarenje (COCI18_planinarenje) | C++17 | 219 ms | 1148 KB |
#include<bits/stdc++.h> using namespace std; vector <vector <int> > g; vector <int> used, mat, mat1; bool dfs(int v, int cnt) { if(used[v] == cnt) { return false; } used[v] = cnt; for(int i = 0; i < g[v].size(); i++){ int to = g[v][i]; if(mat[to] == -1 || dfs(mat[to], cnt)) { mat[to] = v; return true; } } return false; } bool dfs1(int v, int cnt) { if(used[v] == cnt) { return false; } used[v] = cnt; for(int i = 0; i < g[v].size(); i++){ int to = g[v][i]; if(used[to] == cnt) { continue; } if(mat1[to] == -1 || dfs1(mat1[to], cnt)) { mat1[to] = v; return true; } } return false; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; g.resize(2 * n); mat1.resize(2 * n ,-1); mat.resize(2 * n, -1); used.resize(2 * n); for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; b += n; g[a].push_back(b); g[b].push_back(a); } for(int i = 0;i < n; i++) { dfs(i, i + 1); } int cnt1 = 0; for(int i = n; i < n * 2; i++) { if(mat[i] != -1) { cnt1++; } } vector <bool> ans(n); for(int i = 0; i < n; i++) { int st = -1; for(int j = 0; j < 2 * n; j++){ mat1[j] = -1; } for(int j = 0; j < 2 * n; j++) { if(mat[j] != -1 && mat[j] != i) { mat1[mat[j]] = j; } if(mat[j] == i) { st = j; } } used[i] = n + i + 1; if(st != -1) { dfs1(st, n + i + 1); } int cnt2 = 0; for(int j = 0; j < n; j++) { if(mat1[j] != -1) { cnt2++; } } if(cnt1 == cnt2) { ans[i] = true; } else { ans[i] = false; } } for(int i = 0; i < n; i++) { if(ans[i]) { cout << "Mirko\n"; } else { cout << "Slavko\n"; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 360 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 7 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 184 ms | 1016 KB | Output is correct |
2 | Correct | 190 ms | 1148 KB | Output is correct |
3 | Correct | 178 ms | 1024 KB | Output is correct |
4 | Correct | 219 ms | 1060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 632 KB | Output is correct |
2 | Correct | 26 ms | 512 KB | Output is correct |
3 | Correct | 20 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 512 KB | Output is correct |
2 | Correct | 10 ms | 512 KB | Output is correct |
3 | Correct | 20 ms | 512 KB | Output is correct |
4 | Correct | 22 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 640 KB | Output is correct |
2 | Correct | 181 ms | 1024 KB | Output is correct |
3 | Correct | 54 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 640 KB | Output is correct |
2 | Correct | 99 ms | 888 KB | Output is correct |
3 | Correct | 40 ms | 640 KB | Output is correct |
4 | Correct | 50 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 768 KB | Output is correct |
2 | Correct | 46 ms | 764 KB | Output is correct |
3 | Correct | 110 ms | 888 KB | Output is correct |
4 | Correct | 39 ms | 640 KB | Output is correct |