QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375306#2833. HamiltonKevin5307WA 0ms3648kbC++201.5kb2024-04-03 08:09:092024-04-03 08:09:10

Judging History

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

  • [2024-04-03 08:09:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-04-03 08:09:09]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
string grid[2020];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	while(cin>>n)
	{
		for(int i=1;i<=n;i++)
		{
			cin>>grid[i];
			grid[i]=" "+grid[i];
		}
		vector<int> ans;
		ans.pb(1);
		for(int i=2;i<=n;i++)
		{
			if(grid[i][ans[0]]=='1')
				ans.insert(ans.begin()+1,i);
			else
				ans.pb(i);
			char ch='?';
			for(int j=0;j<sz(ans);j++)
			{
				int u=ans[j],v=ans[(j+1)%sz(ans)];
				if(ch=='?')
					ch=grid[u][v];
				else if(ch!=grid[u][v])
					ch='!';
			}
			if(ch!='!') continue;
			while(grid[ans[0]][ans[1]]=='1')
			{
				ans.pb(ans[0]);
				ans.erase(ans.begin());
			}
			while(grid[sz(ans)-2][ans.back()]=='0')
			{
				ans.insert(ans.begin(),ans.back());
				ans.pop_back();
			}
		}
		for(auto x:ans)
			cout<<x<<" ";
		cout<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3648kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

2 1 3 
1 2 3 4 

result:

wrong answer case #1: found 2 indices