#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';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |