QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505097#2833. HamiltonSouthern_DynastyWA 0ms3852kbC++142.9kb2024-08-04 19:48:122024-08-04 19:48:12

Judging History

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

  • [2024-08-04 19:48:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-08-04 19:48:12]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define gt getchar
#define pt putchar
#define fst first
#define scd second
#define SZ(s) ((int)s.size())
#define all(s) s.begin(),s.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
const int N=2005;
using namespace std;
using namespace __gnu_pbds;
typedef pair<int,int> pii;
template<class T,class I> inline void chkmax(T &a,I b){a=max(a,(T)b);}
template<class T,class I> inline void chkmin(T &a,I b){a=min(a,(T)b);}
inline bool __(char ch){return ch>=48&&ch<=57;}
template<class T> inline void read(T &x){
	x=0;bool sgn=0;static char ch=gt();
	while(!__(ch)&&ch!=EOF) sgn|=(ch=='-'),ch=gt();
	while(__(ch)) x=(x<<1)+(x<<3)+(ch&15),ch=gt();
	if(sgn) x=-x;
}
template<class T,class ...I> inline void read(T &x,I &...x1){
	read(x);
	read(x1...);
}
template<class T> inline void print(T x){
	static char stk[70];short top=0;
	if(x<0) pt('-');
	do{stk[++top]=x>=0?(x%10+48):(-(x%10)+48),x/=10;}while(x);
	while(top) pt(stk[top--]);
}
template<class T> inline void printsp(T x){
	print(x);
	putchar(' ');
}
template<class T> inline void println(T x){
	print(x);
	putchar('\n');
}
int n,e[N][N];
inline void solve(){
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			scanf("%1d",&e[i][j]);		
		}
	}
	vector<int> cyc={1,2};
	for(int i=3;i<=n;++i){
		int m=i-1;
		set<int> st;
		for(int x=0;x<m;++x){
			int y=(x+1)%m;
			st.insert(e[cyc[x]][cyc[y]]);
		}
		if(SZ(st)==1){
			int lst=cyc.back();
			cyc.pop_back();
			cyc.eb(i);
			cyc.eb(lst);
		}else{
			for(int C=0;C<m;++C){
				int B=C?C-1:m-1;
				int D=(C+1)%m;
				if(!e[cyc[B]][cyc[C]]&&e[cyc[C]][cyc[D]]){
					if(e[i][cyc[C]]){
						vector<int> vec;
						for(int j=0;j<C;++j) vec.eb(cyc[j]);
						vec.eb(i);
						for(int j=C;j<SZ(cyc);++j) vec.eb(cyc[j]);
					}else{
						vector<int> vec;
						for(int j=0;j<=C;++j) vec.eb(cyc[j]);
						vec.eb(i);
						for(int j=C+1;j<SZ(cyc);++j) vec.eb(cyc[j]);
					}
					break;
				}else if(e[cyc[B]][cyc[C]]&&!e[cyc[C]][cyc[D]]){
					if(!e[i][cyc[C]]){
						vector<int> vec;
						for(int j=0;j<C;++j) vec.eb(cyc[j]);
						vec.eb(i);
						for(int j=C;j<SZ(cyc);++j) vec.eb(cyc[j]);
					}else{
						vector<int> vec;
						for(int j=0;j<=C;++j) vec.eb(cyc[j]);
						vec.eb(i);
						for(int j=C+1;j<SZ(cyc);++j) vec.eb(cyc[j]);
					}
					break;
				}
			}
		}
	}
	int idx=0;
	for(int C=0;C<n;++C){
		int B=C?C-1:n-1,D=(C+1)%n;
		if(e[cyc[B]][cyc[C]]!=e[cyc[C]][cyc[D]]){
			idx=C;
			break;
		}
	}
	for(int i=idx;i<n;++i) printsp(cyc[i]);
	for(int i=0;i<idx;++i) printsp(cyc[i]);
	printf("\n");
}
signed main(){
	while(~scanf("%d",&n)) solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 3 2 
1 3 4 2 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

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

output:

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

result:

ok 4 cases.

Test #3:

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

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 3 4 2 
4 2 1 3 
3 2 0 1 
1 3 2 0 
1 3 2 0 
3 4 2 1 
1 3 4 2 
3 2 0 1 
3 2 0 1 
1 3 2 0 
1 3 2 0 

result:

wrong answer Integer 0 violates the range [1, 4]