Submission #621472

#TimeUsernameProblemLanguageResultExecution timeMemory
621472elkernosTravelling Salesperson (CCO20_day2problem1)C++17
0 / 25
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...