QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#666990#7757. Palm IslandmikuWA 1ms5840kbC++201000b2024-10-22 20:40:402024-10-22 20:40:49

Judging History

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

  • [2024-10-22 20:40:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5840kb
  • [2024-10-22 20:40:40]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define endl '\n'
using namespace std;
using ll =long long ;
using pii =pair<int,int>;
using pll=pair<ll,ll>;
const int N=5e5+10;
ll a[N];
ll b[N];
void solve(){
	int n;
	cin>>n;
	map<int,int>mp;
	map<pii,int>mpx;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int idx=0;deque<ll>dq;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		mp[b[i]]=++idx;
	}
	for(int i=1;i<=n;i++){
		a[i]=mp[a[i]];dq.pb(a[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[i]>a[j])mpx[{a[i],a[j]}]=1;
		}
	}	
	for(int i=1;i<=n*(n-1);){
		if(mpx[{dq[0],dq[1]}]){
			mpx[{dq[0],dq[1]}]=0;
			dq.pb(dq[1]);dq.pb(dq[0]);
			dq.pop_front();cout<<2;i+=2;
		}
		else {dq.pb(dq[0]);i++;}
		cout<<1;
		dq.pop_front();
	}
	if(dq[0]!=1){
		int w=n-dq[0]+1;
		while(w--)cout<<1;
	}
	cout<<endl;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int _=1;
	cin>>_;
	while(_--)solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5796kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

211121
211111111111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5840kb

input:

200
3
3 1 2
2 3 1
4
2 4 1 3
2 1 4 3
4
1 4 2 3
2 1 3 4
5
4 3 2 1 5
2 4 5 3 1
5
2 1 5 4 3
5 2 4 1 3
4
4 3 1 2
1 2 4 3
3
1 2 3
3 1 2
4
1 4 2 3
2 1 4 3
4
1 3 2 4
1 4 3 2
3
3 2 1
1 3 2
3
2 3 1
1 3 2
4
1 4 3 2
3 1 2 4
3
1 2 3
1 3 2
3
3 2 1
2 3 1
5
5 1 3 2 4
2 4 5 1 3
4
4 3 1 2
1 4 3 2
4
1 3 4 2
2 4 3 1
3
...

output:

121211
121111111111
121121211111
12121212111111111111
12111212111111111111
121121211211
121211
121121111111
112112111111
121211
21112111
121121211111
121111
211111
11211121212121112111
121121111111
212112112121
211121
111111111111
21211121212121111111
121121211211111
211112112111
212112112111
212112...

result:

wrong answer On Case#11: After your operations, a[1] = 2 but a[1] = 1. (test case 11)