QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#632489#7757. Palm IslandtsaiWA 0ms3684kbC++14848b2024-10-12 13:28:062024-10-12 13:28:06

Judging History

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

  • [2024-10-12 13:28:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-10-12 13:28:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
int n, a[N], b[N];
void solve(){
	scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++){
        int tmp; scanf("%d", &tmp);
        b[tmp] = i;
    }
	deque<int>q;
    for(int i = 1; i <= n; i++) q.push_back(b[a[i]]);
    int rem = n % 2; n = n - n % 2;
	for(int i = 1; i <= n; i+=2){
		int fir = i, sec = i + 1;
		while(q.front() != fir) q.push_back(q.front()), q.pop_front(), printf("1");
		q.pop_front();
		while(q.front() != sec) q.push_back(q.front()), q.pop_front(), printf("2");
		q.pop_front();
		printf("12"); q.push_back(1), q.push_back(2);
	}
	if(rem) printf("1");
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		solve();
		if(t) printf("\n");
	}
	
	return 0;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1121
1221212

result:

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