QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375727#2833. HamiltonMine_KingWA 1ms3936kbC++141.2kb2024-04-03 15:15:592024-04-03 15:15:59

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 15:15:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3936kb
  • [2024-04-03 15:15:59]
  • 提交

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) {
				if (a[p[i]][p[i + 1]] == a[p[i - 1]][p[i]] || a[p[i]][p[i + 1]] == a[p[i + 1]][p[1]])
					continue;
				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: 3936kb

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: 0
Accepted
time: 1ms
memory: 3892kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
1 2 3 
3 1 2 
1 2 3 

result:

ok 4 cases.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3908kb

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 2 3 4 
1 2 3 4 
1 4 2 3 
3 1 4 2 
1 4 2 3 
4 1 2 3 
1 2 3 4 
3 1 4 2 
1 4 2 3 
4 1 2 3 
1 4 2 3 

result:

wrong answer case #3: found 2 indices