QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372647 | #2833. Hamilton | ckiseki# | WA | 1ms | 3780kb | C++20 | 1.6kb | 2024-03-31 17:04:23 | 2024-03-31 17:04:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
using namespace experimental;
copy(L, R, make_ostream_joiner(cerr, ", "));
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
while (cin >> n) {
vector<string> s(n);
// for (int i = 0; i < n; i++) {
// s[i] = string(n, '0');
// }
// for (int i = 0; i < n; i++) {
// for (int j = 0; j < i; j++)
// if (rand() % 2)
// s[i][j] = s[j][i] = '1';
// }
for (int i = 0; i < n; i++) {
cin >> s[i];
}
vector<int> p = {0, 1, 2};
for (int i = 3; i < n; i++) {
int cnt = 0;
int pos = 0;
for (int j = 0; j < i; j++)
if (s[p[j]][p[(j+1)%i]] != s[p[(j+1)%i]][p[(j+2)%i]]) {
pos = (j + 1) % i;
++cnt;
}
assert(cnt <= 2);
if (s[i][p[pos]] == s[p[pos]][p[(pos + 1) % i]]) {
p.insert(p.begin() + pos, i);
} else {
p.insert(p.begin() + (pos + 1) % i, i);
}
}
for (int i = 0; i < n; i++) {
cout << p[i] + 1 << (i+1==n ? '\n' : ' ');
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3780kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 4 1 2 3
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
1 2 3 1 2 3 1 2 3 1 2 3
result:
wrong answer case #3: found 2 indices