QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559148#8835. GoodmanAChievedreaM#WA 0ms7784kbC++171.2kb2024-09-11 20:30:412024-09-11 20:30:43

Judging History

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

  • [2024-09-11 20:30:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7784kb
  • [2024-09-11 20:30:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using db=double;
const ll N=1e6+5;
typedef pair<ll,ll>PLL;
#define fi first
#define se second
ll a[N],ans[N],vis[N];
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll t,n;
	t=1;
	cin>>t;
	while(t--)
	{
		cin>>n;
		ll cnt=0;
		for(ll i=1;i<=n;i++)
		{
			vis[i]=0;
			cin>>a[i];
		
		}
		ll l=1,r=n;
		while(l<=r)
		{
			if(l==r)
			{
				if(!vis[l])
					ans[++cnt]=a[l],vis[l]=1;
				l++,r--;
			}
			else 
			{
				while(vis[r])
					r--;
				while(vis[l])
					l++;
				if(l>r)break;
				else if(l==r)
				{
					if(!vis[l])
					ans[++cnt]=a[l],vis[l]=1;
					l++,r--;
				}
				else 
				{
					ll f=0;
					if(a[l]==l)
					{
						f=1;
						ans[++cnt]=a[l],vis[l]=1;
					}
					if(a[r]==r)
					{
						f=1;
						ans[++cnt]=a[r],vis[r]=1;
					}
					if(f==0)
					{
						if(a[l]>a[r])
						{
							ans[++cnt]=a[r],vis[r]=1;
							ans[++cnt]=a[l],vis[l]=1;
						}
						else 
						{
							ans[++cnt]=a[l],vis[l]=1;
							ans[++cnt]=a[r],vis[r]=1;
						}
						l++,r--;
					}
				}
			}
		}
		cout<<ans[1];
		for(ll i=2;i<=cnt;i++)
			cout<<' '<<ans[i];
		cout<<'\n';
	}
}

詳細信息

Test #1:

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

input:

2
4
1 2 3 4
6
6 5 4 3 2 1

output:

1 4 2 3
1 6 2 5 3 4

result:

ok Correct (2 test cases)

Test #2:

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

input:

873
6
1 5 2 4 6 3
6
5 1 6 4 3 2
4
1 4 3 2
6
2 1 6 5 4 3
6
4 5 1 3 6 2
6
6 2 1 5 4 3
5
1 5 4 3 2
6
1 2 6 3 5 4
4
2 1 3 4
6
1 6 4 2 3 5
6
6 1 3 5 2 4
6
2 1 4 5 3 6
6
3 4 1 5 2 6
6
4 1 5 2 6 3
6
5 2 1 4 6 3
6
4 1 6 2 3 5
6
5 1 3 4 6 2
6
6 2 5 4 1 3
6
6 2 5 1 4 3
6
5 2 3 6 4 1
6
6 1 2 5 4 3
6
2 3 4 6 1 ...

output:

1 3 5 2 6 4
2 5 1 3 4 6
1 2 4 3
2 3 1 4 5 6
2 4 5 6 1 3
3 6 2 1 4 5
1 2 5 3 4
1 2 4 6 5 3
4 3 1 2
1 5 6 3 4 2
4 6 1 2 3 5
6 2 3 1 5 4
6 2 3 4 5 1
3 4 1 6 2 5
3 5 2 1 6 4
4 5 1 3 2 6
2 5 1 6 3 4
3 6 2 1 5 4
3 6 2 4 5 1
1 5 2 3 4 6
3 6 1 4 2 5
2 5 1 3 4 6
3 5 1 6 4 2
4 5 2 3 6 1
6 1 4 2 3 5
3 5 2 1 4 ...

result:

wrong answer Jury found better answer than participant (test case 1)