QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375722 | #2833. Hamilton | Mine_King | WA | 1ms | 3944kb | C++14 | 1.1kb | 2024-04-03 15:13:12 | 2024-04-03 15:13:13 |
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;
// eprintf("%d %d\n", a[p[1]][p[2]], a[p[2]][p[1]]);
if (!b) {
for (int j = i; j >= 1; j--) swap(p[j], p[j + 1]);
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: 3944kb
input:
3 001 000 100 4 0000 0000 0000 0000
output:
3 2 1 4 3 2 1
result:
ok 2 cases.
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
3 000 000 000 3 010 100 000 3 011 100 100 3 011 101 110
output:
3 2 1 3 2 1 3 2 1 3 2 1
result:
wrong answer case #2: found 2 indices