QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375722#2833. HamiltonMine_KingWA 1ms3944kbC++141.1kb2024-04-03 15:13:122024-04-03 15:13:13

Judging History

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

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

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