QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375709#2833. HamiltonMine_KingWA 1ms3872kbC++141023b2024-04-03 15:05:092024-04-03 15:05:09

Judging History

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

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

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