QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519151#7757. Palm IslandQF_love_younger_sisterWA 1ms3640kbC++231.1kb2024-08-14 16:46:172024-08-14 16:46:18

Judging History

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

  • [2024-08-14 16:46:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-08-14 16:46:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int a[N],b[N],c[N];
int que[N*N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,t;
	cin >> t;
	while(t--){
		vector<int> cz;
		cin >> n;
		for(int i=1;i<=n;i++){
			cin >> a[i];
		}
		for(int i=1;i<=n;i++){
			cin >> b[i];
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(b[i]==a[j]){
					c[j]=i;
					que[j]=i;
				}
			}
		}
//		for(int i=1;i<=n;i++){
//			cout << que[i] << " ";
//		}
//		cout << "\n";
		int czs=1,st=1,en=n;
		while(czs<=n*n){
			if(que[st]<que[st+1]){
				cz.push_back(2);
				en++;
				que[en]=que[st+1];
				que[st+1]=que[st];
				st++;
			}
			else{
				cz.push_back(1);
				en++;
				que[en]=que[st];
				st++;
			}
			if(czs>=n*(n-1)){
				int flag=1;
				for(int i=st;i<=en;i++){
					if(que[i]!=i-st+1){
						flag=0;
						break;
					}
				}
				if(flag){
					break;
				}
			}
			czs++;
		}
		int len2=cz.size();
		for(int i=0;i<len2;i++){
			cout << cz[i];
		}
		cout << "\n";
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1222222
122222222222

result:

ok Correct. (2 test cases)

Test #2:

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

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:

2122222
2222222222222222
2122222222222
2122222222222222222222222
2122222222222222222222222
2122222222222222
2122222
2122222222222222
22222222222222
2122222
1122222
2122222222222
2222222
122222
2212222222222222222222222
2122222222222222
1112222222222222
1222222
222222222222
1212222222222222222222
211...

result:

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