#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN =2e3+5;
char a[MAXN][MAXN];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
for (int i =1 ; i <= n; ++i) {
for (int j = 1; j < i; ++j) {
cin >> a[i][j];
a[j][i] = a[i][j];
}
}
for (int s = 1; s <= n; s++) {
vector<int> red, blue;
for (int i = 1; i <= n+1; ++i) {
if (i == s) continue;
if (i == n+1) i = s;
if (red.empty() || a[red.back()][i] == 'R') {
red.push_back(i);
} else if (blue.empty() || a[blue.back()][i] == 'B') {
blue.push_back(i);
} else if (a[red.back()][blue.back()] == 'R') {
red.push_back(blue.back());
blue.pop_back();
red.push_back(i);
} else {
blue.push_back(red.back());
red.pop_back();
blue.push_back(i);
}
if (i == s) i = n+1;
}
if (!blue.empty() && blue.back() == s) swap(red,blue);
cout << n << "\n";
reverse(red.begin(), red.end());
for (int i : red) cout << i << " ";
for (int i : blue) cout << i << " ";
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
328 KB |
Output is correct |
16 |
Correct |
323 ms |
24044 KB |
Output is correct |
17 |
Correct |
330 ms |
24064 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
326 ms |
23932 KB |
Output is correct |
20 |
Correct |
355 ms |
24012 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
344 ms |
24004 KB |
Output is correct |
23 |
Correct |
334 ms |
23808 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
341 ms |
23844 KB |
Output is correct |
26 |
Correct |
337 ms |
24008 KB |
Output is correct |
27 |
Correct |
21 ms |
2376 KB |
Output is correct |
28 |
Correct |
320 ms |
24084 KB |
Output is correct |
29 |
Correct |
359 ms |
23872 KB |
Output is correct |
30 |
Correct |
353 ms |
23992 KB |
Output is correct |
31 |
Correct |
367 ms |
24000 KB |
Output is correct |
32 |
Correct |
349 ms |
23864 KB |
Output is correct |
33 |
Correct |
328 ms |
24064 KB |
Output is correct |
34 |
Correct |
339 ms |
23884 KB |
Output is correct |
35 |
Correct |
381 ms |
24004 KB |
Output is correct |
36 |
Correct |
345 ms |
24008 KB |
Output is correct |
37 |
Correct |
324 ms |
23892 KB |
Output is correct |
38 |
Correct |
377 ms |
23920 KB |
Output is correct |
39 |
Correct |
363 ms |
23864 KB |
Output is correct |
40 |
Correct |
336 ms |
23940 KB |
Output is correct |
41 |
Correct |
328 ms |
23844 KB |
Output is correct |
42 |
Correct |
337 ms |
23996 KB |
Output is correct |
43 |
Correct |
325 ms |
23912 KB |
Output is correct |
44 |
Correct |
328 ms |
23932 KB |
Output is correct |
45 |
Correct |
327 ms |
24008 KB |
Output is correct |
46 |
Correct |
328 ms |
23892 KB |
Output is correct |
47 |
Correct |
334 ms |
24032 KB |
Output is correct |
48 |
Correct |
337 ms |
23968 KB |
Output is correct |
49 |
Correct |
322 ms |
24084 KB |
Output is correct |
50 |
Correct |
321 ms |
23852 KB |
Output is correct |
51 |
Correct |
317 ms |
23856 KB |
Output is correct |
52 |
Correct |
340 ms |
24016 KB |
Output is correct |
53 |
Correct |
321 ms |
23968 KB |
Output is correct |
54 |
Correct |
325 ms |
24120 KB |
Output is correct |
55 |
Correct |
352 ms |
24036 KB |
Output is correct |
56 |
Correct |
364 ms |
24048 KB |
Output is correct |
57 |
Correct |
401 ms |
24028 KB |
Output is correct |
58 |
Correct |
410 ms |
24016 KB |
Output is correct |
59 |
Correct |
358 ms |
24096 KB |
Output is correct |
60 |
Correct |
351 ms |
24012 KB |
Output is correct |
61 |
Correct |
339 ms |
24072 KB |
Output is correct |
62 |
Correct |
342 ms |
24140 KB |
Output is correct |
63 |
Correct |
339 ms |
24024 KB |
Output is correct |
64 |
Correct |
356 ms |
24060 KB |
Output is correct |
65 |
Correct |
333 ms |
24012 KB |
Output is correct |
66 |
Correct |
331 ms |
24040 KB |
Output is correct |
67 |
Correct |
338 ms |
24144 KB |
Output is correct |
68 |
Correct |
326 ms |
24024 KB |
Output is correct |
69 |
Correct |
357 ms |
24048 KB |
Output is correct |
70 |
Correct |
340 ms |
24040 KB |
Output is correct |
71 |
Correct |
352 ms |
24092 KB |
Output is correct |
72 |
Correct |
338 ms |
24000 KB |
Output is correct |
73 |
Correct |
345 ms |
24048 KB |
Output is correct |
74 |
Correct |
368 ms |
24012 KB |
Output is correct |
75 |
Correct |
331 ms |
24072 KB |
Output is correct |
76 |
Correct |
331 ms |
24012 KB |
Output is correct |
77 |
Correct |
367 ms |
24008 KB |
Output is correct |
78 |
Correct |
439 ms |
23972 KB |
Output is correct |
79 |
Correct |
373 ms |
24048 KB |
Output is correct |
80 |
Correct |
342 ms |
24072 KB |
Output is correct |
81 |
Correct |
364 ms |
24104 KB |
Output is correct |
82 |
Correct |
381 ms |
24064 KB |
Output is correct |
83 |
Correct |
409 ms |
23728 KB |
Output is correct |
84 |
Correct |
373 ms |
24040 KB |
Output is correct |
85 |
Correct |
388 ms |
23960 KB |
Output is correct |
86 |
Correct |
389 ms |
23768 KB |
Output is correct |
87 |
Correct |
23 ms |
2388 KB |
Output is correct |
88 |
Correct |
21 ms |
2280 KB |
Output is correct |
89 |
Correct |
337 ms |
24128 KB |
Output is correct |
90 |
Correct |
343 ms |
24124 KB |
Output is correct |
91 |
Correct |
21 ms |
2308 KB |
Output is correct |
92 |
Correct |
21 ms |
2380 KB |
Output is correct |
93 |
Correct |
330 ms |
24064 KB |
Output is correct |
94 |
Correct |
346 ms |
24048 KB |
Output is correct |
95 |
Correct |
22 ms |
2380 KB |
Output is correct |
96 |
Correct |
21 ms |
2376 KB |
Output is correct |
97 |
Correct |
344 ms |
24072 KB |
Output is correct |
98 |
Correct |
343 ms |
23996 KB |
Output is correct |