# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
964544 |
2024-04-17T05:29:11 Z |
pcc |
Growing Trees (BOI11_grow) |
C++17 |
|
1000 ms |
3412 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 1e5+10;
struct BIT{
int bit[mxn];
void modify(int p,int v){
if(!p)p = 1;
for(;p<mxn;p+=p&-p)bit[p] += v;
return;
}
int getval(int p){
int re = 0;
for(;p>0;p-= p&-p)re += bit[p];
return re;
}
};
int arr[mxn];
int N,Q;
BIT bit;
int getleft(int tar){
int l = 0,r = N+1;
while(l != r){
int mid = (l+r)>>1;
if(bit.getval(mid)>=tar)r = mid;
else l = mid+1;
}
return l;
}
int getright(int tar){
int l = 0,r = N+1;
while(l != r){
int mid = (l+r)>>1;
if(bit.getval(mid)<=tar)l = mid+1;
else r = mid;
}
return l;
}
void add(int a,int b){
a= getleft(a);
b = min(N+1,a+b-1);
if(a>N)return;
int lp = getleft(bit.getval(b));
int rp = getright(bit.getval(b))-1;
if(a != lp){
bit.modify(a,1);
bit.modify(lp,-1);
}
int len = b-lp+1;
bit.modify(rp-len+1,1);
bit.modify(rp+1,-1);
return;
}
int btw(int a,int b){
int ta = getleft(a);
int tb = getleft(b+1);
return tb-ta;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
for(int i = 1;i<=N;i++)cin>>arr[i];
sort(arr+1,arr+N+1);
for(int i = 1;i<=N;i++)bit.modify(i,arr[i]-arr[i-1]);
while(Q--){
char t;
int a,b;
cin>>t>>a>>b;
if(t == 'F')add(b,a);
else cout<<btw(a,b)<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
2396 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
484 KB |
Output is correct |
2 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
856 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
1372 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1038 ms |
1572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
2136 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
90 ms |
2864 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
2644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
3412 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |