QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#508450#7660. Investigating Frog Behaviour on Lily Pad PatternsPoknikWA 1ms5676kbC++14875b2024-08-07 15:42:472024-08-07 15:42:47

Judging History

This is the latest submission verdict.

  • [2024-08-07 15:42:47]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5676kb
  • [2024-08-07 15:42:47]
  • Submitted

answer

#include<bits/stdc++.h>
#define int  long long
using namespace std;
const int N=1e6+2*1e5+1000;
int a[N];
int p[N];
signed main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	cin>>n;
	int max1=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		max1=max(max1,x);
		a[x]=1;
	}
	int q;
	cin>>q;
	int end=q+max1+100;
	int pos;
	for(int i=2;i<=end;i++){
		if(a[i]==0){
			pos=i;
			break;
		}
	}
	p[1]=pos;
	for(int i=2;i<=end;i++){
		if(a[i]==1){
			p[i]=p[i-1];
		}
		else {
			for(int j=i+1;j<=end;j++){
				if(a[j]==0){
					p[i]=j;
					break;
				}
			}	
		}
	}
	for(int i=1;i<=q;i++){
		int x;
		cin>>x;
		if(a[p[x]]!=1){
			cout<<p[x]<<endl;
			a[x]=0;
			a[p[x]]=1;
		}
		else{
			while(a[p[x]]==1){
				p[x]=p[p[x]];
			}
			cout<<p[x]<<endl;
			a[x]=0;
			a[p[x]]=1;
		}
		
		
	}
	
	
}

详细

Test #1:

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

input:

5
1 2 3 5 7
3
1
2
4

output:

4
6
8

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 5660kb

input:

5
1 2 3 5 7
4
1
1
1
1

output:

4
6
8
9

result:

ok 4 lines

Test #3:

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

input:

5
1 2 3 4 5
20
1
4
4
3
5
3
3
5
2
2
5
4
1
4
2
3
1
5
3
3

output:

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

result:

wrong answer 4th lines differ - expected: '4', found: '9'