# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
621472 | elkernos | Travelling Salesperson (CCO20_day2problem1) | C++17 | 0 ms | 212 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;
int32_t main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector col(n + 1, vector<bool>(n + 1));
for(int i = 2; i <= n; i++) {
for(int j = 1; j < i; j++) {
char c;
cin >> c;
col[i][j] = col[j][i] = (c == 'R');
}
}
for(int s = 1; s <= n; s++) {
vector<int> one{s}, two;
for(int i = 1; i <= n; i++) {
if(i == s) {
continue;
}
if(one.empty() || col[one.back()][i]) {
one.push_back(i);
}
else if(two.empty() || !col[two.back()][i]) {
two.push_back(i);
}
else if(col[one.back()][two.back()]) {
one.push_back(two.back());
two.pop_back();
one.push_back(i);
}
else {
two.push_back(one.back());
one.pop_back();
two.push_back(i);
}
}
cout << n << '\n';
for(int i : one) {
cout << i << " ";
}
for(int i : two) {
cout << i << " ";
}
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |