QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375308#2833. HamiltonKevin5307WA 1ms3644kbC++201.5kb2024-04-03 08:10:472024-04-03 08:10:48

Judging History

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

  • [2024-04-03 08:10:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-04-03 08:10:47]
  • 提交

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[0][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: 100
Accepted
time: 1ms
memory: 3636kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

3 2 1 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

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

output:

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

result:

ok 4 cases.

Test #3:

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

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

result:

wrong answer case #3: found 2 indices