# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242455 | MatesV13 | Izlet (COI19_izlet) | C++11 | 640 ms | 90364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |