QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21851#2833. HamiltonDaBenZhongXiaSongKuaiDi#WA 3ms3568kbC++141021b2022-03-08 16:54:122022-05-08 04:09:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 04:09:49]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3568kb
  • [2022-03-08 16:54:12]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
char e[2005][2005];
vector <int> v;
signed main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while(cin >> n)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
				cin >> e[i][j];
		}
		v.clear();
		v.push_back(1);
		v.push_back(2);
		v.push_back(3);
		for(int i=4;i<=n;i++)
		{
			int mn=1e9,pos=0,N=v.size();
			for(int j=0;j<N;j++)
			{
				int w=0;
				if(e[v[(j-1+N)%N]][v[j]]!=e[v[j]][v[(j+1)%N]]) --w;
				if(e[v[j]][v[(j+1)%N]]!=e[v[(j+1)%N]][v[(j+2)%N]]) --w;
				if(e[v[(j-1+N)%N]][v[j]]!=e[v[j]][i]) ++w;
				if(e[v[j]][i]!=e[i][v[(j+1)%N]]) ++w;
				if(e[i][v[(j+1)%N]]!=e[v[(j+1)%N]][v[(j+2)%N]]) ++w;
				if(w<mn) mn=w,pos=j;
			}
			vector <int> nxt;
			for(int i=0;i<=pos;i++) nxt.push_back(v[i]);
			nxt.push_back(i);
			for(int i=pos+1;i<N;i++) nxt.push_back(v[i]);
			swap(nxt,v);
		}
		for(auto t:v)
			cout << t << " ";
		cout << "\n";
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3520kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 4 2 3 

result:

ok 2 cases.

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3568kb

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