QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#508445 | #7660. Investigating Frog Behaviour on Lily Pad Patterns | Poknik | WA | 1ms | 5656kb | C++14 | 851b | 2024-08-07 15:39:00 | 2024-08-07 15:39:01 |
Judging History
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[p[x]]=1;
}
else{
while(a[p[x]]==1){
p[x]=p[p[x]];
}
cout<<p[x]<<endl;
a[p[x]]=1;
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5616kb
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: 5620kb
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: 0ms
memory: 5656kb
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'