QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375333#2833. Hamiltonwsc2008RE 0ms0kbC++141.3kb2024-04-03 09:13:462024-04-03 09:13:47

Judging History

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

  • [2024-04-03 09:13:47]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-03 09:13:46]
  • 提交

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const ll N=2e3+9;
ll T,n;
char e[N][N];
void solve(){
	rep(i,1,n)scanf("%s",e[i]+1);
	vector<ll>ans(1,1);
	rep(i,2,n){
		ll fl=1,lst=-1;
		rep(j,0,(ll)ans.size()-2){
			ll es=e[ans[j]][ans[j+1]]-'0';
			if((!(~lst))||es==lst)lst=es;
			else fl=0;
		}
		if(fl)ans.push_back(i);
		else {
			rep(j,0,(ll)ans.size()-3){
				ll es1=e[ans[j]][ans[j+1]]-'0';
				ll es2=e[ans[j+1]][ans[j+2]]-'0';
				if(es1==0||es2==1)continue;
				ll es3=e[ans[j+1]][i]-'0';
				if(!es3)ans.insert(ans.begin()+j,i);
				else ans.insert(ans.begin()+j+1,i);
			}
		}
	}
	for(ll x:ans)write(x),putchar(' ');
	putchar('\n');
}
bool Med;
int main(){
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
	while(cin>>n)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

3
001
000
100
4
0000
0000
0000
0000

output:


result: