QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#691564 | #7660. Investigating Frog Behaviour on Lily Pad Patterns | Dung1604 | WA | 92ms | 4696kb | C++20 | 1.9kb | 2024-10-31 12:01:46 | 2024-10-31 12:01:48 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 1000000007
using namespace std;
struct node{
bool state = false;
int val = inf;
};
const int limit = 10000;
node it[limit*4];
int frog[200005];
void build(int index, int L, int R){
if(L >= R){
it[index].val = L;
return;
}
int mid = (L + R)/2;
build(2*index, L, mid);
build(2*index + 1, mid + 1, R);
it[index].val = min(it[index*2].val, it[2*index + 1].val);
}
void update(int index, int L, int R, int l, int r, bool state){
if(l > R || L > r){
return;
}
if(l <= L && R <= r){
it[index].state =state;
if(it[index].state) it[index].val = inf;
else it[index].val= l;
return;
}
int mid = (L + R)/2;
update(2*index, L, mid , l, r, state);
update(2*index + 1, mid +1 , R, l, r, state);
it[index].val = min(it[2*index].val , it[2*index +1 ].val);
}
int get(int index , int L, int R, int l, int r){
if(l > R || L > r){
return inf;
}
if(l <= L && R <= r){
return it[index].val;
}
int mid = (L + R)/2;
int left = get(2*index , L, mid, l,r);
int right = get(2*index+ 1, mid + 1, R, l, r);
return min(left, right);
}
void solve(){
int n;
cin >> n;
build(1, 1, limit);
for(int i= 1 ; i <= n; i++){
cin >> frog[i];
update(1, 1, limit, frog[i], frog[i], true);
}
int q;
cin >> q;
while(q--){
int pos;
cin >> pos;
int cur = frog[pos];
update(1, 1, limit, frog[pos], frog[pos], false);
int nxt = get(1, 1,limit, cur + 1,limit );
cout << nxt << endl;
frog[pos] = nxt;
update(1, 1, limit, frog[pos], frog[pos], true);
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3876kb
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: 3964kb
input:
5 1 2 3 5 7 4 1 1 1 1
output:
4 6 8 9
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
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 7 5 9 10 3 4 11 10 7 12 5 10 8 13 11 14
result:
ok 20 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
10 2 4 6 7 8 9 10 12 13 14 1000 4 5 4 6 2 5 2 9 6 10 6 2 1 3 7 3 9 5 2 10 8 7 6 7 4 7 9 4 4 4 5 2 6 1 10 9 10 3 7 10 5 9 5 8 4 8 10 9 1 7 10 8 10 6 7 7 10 8 1 2 9 10 2 3 8 7 2 7 2 2 1 10 3 3 2 8 9 6 10 1 7 9 10 6 5 9 9 6 4 9 10 3 3 10 5 4 8 5 8 4 9 5 5 3 9 7 5 5 4 6 1 8 6 7 9 2 2 4 9 3 6 4 6 8 4 4 3...
output:
11 15 16 11 5 17 7 15 13 18 14 8 3 7 11 9 19 20 10 21 13 12 15 14 17 16 22 18 19 23 24 11 17 4 25 26 27 10 18 28 25 27 26 14 24 15 29 28 5 19 30 16 31 18 20 21 32 17 6 12 29 33 13 11 19 22 14 23 15 16 7 34 12 13 17 20 30 19 35 8 25 31 36 21 27 32 33 22 26 34 37 14 15 38 28 27 21 29 23 28 35 30 31 16...
result:
ok 1000 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
20 1 2 3 4 6 7 8 9 10 11 12 13 14 15 17 18 20 21 22 24 1000 5 13 20 2 2 3 3 16 6 9 4 16 13 6 10 4 14 13 10 18 17 16 2 11 10 11 16 15 16 8 20 7 2 15 9 2 10 7 15 9 7 11 7 18 10 20 1 12 6 9 19 17 4 7 13 8 17 7 14 1 17 11 17 1 4 4 4 5 14 1 14 6 13 3 3 16 20 13 9 20 1 11 2 12 15 2 9 7 3 6 15 7 11 12 17 5...
output:
16 19 25 5 6 5 14 23 18 24 5 26 23 19 18 7 27 28 23 29 21 30 10 15 26 18 31 20 32 11 30 9 12 23 25 15 31 10 24 26 12 20 17 33 34 31 2 18 23 29 25 22 8 19 30 12 26 21 28 3 27 22 35 4 9 10 11 17 36 5 37 26 36 16 19 38 32 39 30 36 6 23 16 20 27 18 31 22 21 28 29 24 26 22 40 19 23 27 30 41 37 32 42 29 3...
result:
ok 1000 lines
Test #6:
score: -100
Wrong Answer
time: 92ms
memory: 4696kb
input:
200000 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 64 65 66 67 68 69 71 72 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 103 105 106...
output:
1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 1000000007 5933 1000000007 100000000...
result:
wrong answer 1st lines differ - expected: '215571', found: '1000000007'