# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242455 | 2020-06-27T18:05:55 Z | MatesV13 | Izlet (COI19_izlet) | C++11 | 640 ms | 90364 KB |
#include <bits/stdc++.h> using namespace std; int sub, n, boje[3005][3005]; int b[3005], cur, par; vector<int> c[3005]; deque<pair<int, int> > xx; int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> sub; if (sub==1){ cin >> n; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) cin >> boje[i][j]; xx.push_front(make_pair(1, 0)); while(!xx.empty()){ cur = (xx.front()).first; par = (xx.front()).second; xx.pop_front(); if (b[cur]) continue; c[cur].push_back(par); c[par].push_back(cur); b[cur]=(b[par]+boje[cur][par])%2+1; for (int i=1; i<=n; i++){ if (b[i]) continue; if (boje[cur][i]==1) xx.push_front(make_pair(i, cur)); else xx.push_back(make_pair(i, cur)); } } for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl; for (int i=1; i<=n; i++){ for (int j=0; j<c[i].size(); j++){ if (boje[i][c[i][j]]){ cout << i << " " << c[i][j] << endl; boje[c[i][j]][i]=0; } } } } else if (sub==2){ cin >> n; for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) cin >> boje[i][j]; for (int i=1; i<=n; i++){ if (boje[i][1]==i) b[i]=i; else { for (int j=2; j<=i; j++) if (boje[i][j]==boje[i][j-1]){ b[i]=b[j-1]; break; } } } for (int i=1; i<=n; i++) cout << b[i] << " "; cout << endl; for (int i=1; i<n; i++) cout << i << " " << i+1 << endl; } else cout << "Sori, me is stupid!"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 608 ms | 90360 KB | Output is correct |
3 | Correct | 640 ms | 90364 KB | Output is correct |
4 | Correct | 634 ms | 89204 KB | Output is correct |
5 | Correct | 632 ms | 88556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 566 ms | 53496 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 608 ms | 90360 KB | Output is correct |
3 | Correct | 640 ms | 90364 KB | Output is correct |
4 | Correct | 634 ms | 89204 KB | Output is correct |
5 | Correct | 632 ms | 88556 KB | Output is correct |
6 | Incorrect | 566 ms | 53496 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |