QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375709 | #2833. Hamilton | Mine_King | WA | 1ms | 3872kb | C++14 | 1023b | 2024-04-03 15:05:09 | 2024-04-03 15:05:09 |
Judging History
answer
// 君の人生は月明かりだ、有りがちだなんて言わせるものか
// Think twice, code once.
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;
int n, a[2005][2005], p[2005];
int main() {
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) scanf("%1d", &a[i][j]);
p[1] = 1;
for (int i = 1; i < n; i++) {
int b = 0;
for (int j = 1; j < i; j++)
if (a[p[j]][p[j + 1]] != a[p[j + 1]][p[(j + 1) % i + 1]]) {b = j; break;}
p[i + 1] = i + 1;
if (!b) continue;
if (a[p[b]][i + 1] == a[p[b]][p[b % i + 1]])
for (int j = i; j > b; j--) swap(p[j], p[j + 1]);
else for (int j = i; j >= b; j--) swap(p[j], p[j + 1]);
}
for (int i = 1; i <= n; i++) printf("%d ", p[i]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3872kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
1 2 3 1 2 3 4
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3764kb
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