QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375526#2833. Hamilton275307894aWA 1ms4052kbC++141.6kb2024-04-03 11:58:542024-04-03 11:58:54

Judging History

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

  • [2024-04-03 11:58:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4052kb
  • [2024-04-03 11:58:54]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2000+5,M=6000+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-8;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,st[N],sh,col[N];char s[N][N];
void Solve(){
	int i,j;while(~scanf("%d",&n)){
		for(i=1;i<=n;i++) scanf("%s",s[i]+1);
		st[1]=1;
		for(i=2;i<=n;i++){
			for(j=1;j<i;j++) col[j]=s[st[j]][st[j%(i-1)+1]];
			st[i]=i;
			if(count(col+1,col+i,col[1])==i-1){
				if(col[1]^s[st[i-1]][st[i]]) rotate(st+1,st+i,st+i+1);
			}else{
				int pt=find(col+1,col+i,col[1]^1)-col;
				if(s[st[pt]][i]==col[1]) rotate(col+pt+1,col+i,col+i+1);
				else rotate(col+pt,col+i,col+i+1);
			}
		}
		for(i=1;i<=n;i++) printf("%d%c",st[i]," \n"[i==n]);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4024kb

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: 0ms
memory: 4052kb

input:

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

output:

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

result:

wrong answer case #2: found 2 indices