QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#508488#7660. Investigating Frog Behaviour on Lily Pad PatternsPoknikWA 40ms8568kbC++141.0kb2024-08-07 16:21:562024-08-07 16:21:56

Judging History

This is the latest submission verdict.

  • [2024-08-07 16:21:56]
  • Judged
  • Verdict: WA
  • Time: 40ms
  • Memory: 8568kb
  • [2024-08-07 16:21:56]
  • Submitted

answer

#include<bits/stdc++.h>
#define INF 100100
#define maxx 100000007
#define pi 3.14159265359
using namespace std;
typedef long long LL;
set<int> emptypos;
int pos[INF]={0};
int qing[INF]={0};
int myfind(int x)
{
	for(int i=1;i<=INF;i++)
	{
		if(pos[i]==x)
		{
			return i;
		}
	}
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
	//freopen("in.txt","r",stdin);
	int n;
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		pos[x]=i;
		qing[i]=x;
	}
	for(int i=1;i<=qing[n];i++)
	{
		if(pos[i]==0)
			emptypos.insert(i);
	}
//    set<int>::iterator it;
//    for(it=emptypos.begin();it!=emptypos.end();it++)
//        cout<<*it<<" ";
	for(int i=qing[n]+1;i<=INF;i++)
		emptypos.insert(i);
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&x);
		int xx=qing[x];
		int y=*upper_bound(emptypos.begin(),emptypos.end(),xx);
		printf("%d\n",y);
		emptypos.erase(y);
		emptypos.insert(xx);
		pos[y]=x;
		pos[xx]=0;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 8504kb

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: 17ms
memory: 8500kb

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: 40ms
memory: 8568kb

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
4
9
5
10
11
3
5
12
5
2
13
4
14
2
15
5
16

result:

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