QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575869#7757. Palm Islandasdfo123WA 0ms3644kbC++14925b2024-09-19 17:06:342024-09-19 17:06:34

Judging History

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

  • [2024-09-19 17:06:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2024-09-19 17:06:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int a[1005],b[1005];
int pre[1005];
int c[1005];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		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-1;i++) pre[b[i+1]] = b[i];
		pre[b[1]] = b[n];
		for(int i = n;i>=2;i--)
		{
			int j = 1;
			for(int k = 1;k <= i-1;k++) 
				if(a[k] == pre[a[i]]) 
				{
					j = k;
					break;
				}
//			cout<<"j: "<<j<<endl;
			for(int k = 1;k <= j-1;k++) cout<<"1";
			for(int k = j+1;k <= i-1;k++) cout<<"2";
			for(int k = 1;k <= n-i+2;k++) cout<<"1";
			for(int k = j+1;k <= i-2;k++) a[k-1] = a[k];
			a[i-1] = a[j];
		} 
//		for(int i = 1;i <= n;i++)  cout<<a[i]<<" ";
//		cout<<endl;
		for(int i = 1;i <= n;i++)  
		{
			if(a[i] == b[1])
			{
				for(int j = 1;j <= i-1;j++) cout<<"1";
				break;
			}
		}
		cout<<endl;
	}
 } 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1111111
111121111111

result:

ok Correct. (2 test cases)

Test #2:

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

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:

11111111
121121111111
221121111111
22211221112111111111
12211221112111111111
11111111111111
11111111
121121111111
221121111111
11111111
21111111
221121111111
211111
211111
11111111111111111111111
121121111111
221121111111111
1111111
111111111111
12211221112111111111
121121111111111
221121111111
1111...

result:

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