# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
254344 |
2020-07-29T21:20:41 Z |
amiratou |
Tenis (COI19_tenis) |
C++14 |
|
300 ms |
32672 KB |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[3][100005],A[100005],st[400005],lazy[400005],pos[100005][3],arr[100005],n;
multiset<int,greater<int> > lst[100005];
void build(int node,int l,int r){
if(l==r){
st[node]=A[l];
return;
}
int med=(l+r)>>1;
build(node*2,l,med),build(node*2+1,med+1,r);
st[node]=min(st[node*2],st[node*2+1]);
}
void prop(int node,int l,int r){
if(lazy[node]){
st[node]+=lazy[node];
if(l!=r){
lazy[node*2]+=lazy[node];
lazy[node*2+1]+=lazy[node];
}
lazy[node]=0;
}
}
void update(int node,int l,int r,int i,int j,int val){
prop(node,l,r);
if(l>j||r<i)
return;
if(l>=i && r<=j){
st[node]+=val;
if(l!=r){
lazy[node*2]+=val;
lazy[node*2+1]+=val;
}
return ;
}
int med=(l+r)>>1;
update(node*2,l,med,i,j,val),update(node*2+1,med+1,r,i,j,val);
st[node]=min(st[node*2],st[node*2+1]);
}
int query(int node,int l,int r,int i){
prop(node,l,r);
if(l>i ||r<i)
return INF;
if(l==r)
return st[node];
int med=(l+r)>>1;
return min(query(node*2,l,med,i),query(node*2+1,med+1,r,i));
}
void update(int t,int a,int b){
update(1,0,n-1,*lst[b].begin(),n-1,1);
update(1,0,n-1,*lst[a].begin(),n-1,1);
lst[a].erase(lst[a].find(pos[a][t]));
lst[b].erase(lst[b].find(pos[b][t]));
swap(pos[a][t],pos[b][t]);
lst[a].insert(pos[a][t]);
lst[b].insert(pos[b][t]);
update(1,0,n-1,*lst[b].begin(),n-1,-1);
update(1,0,n-1,*lst[a].begin(),n-1,-1);
}
bool query(int x){
int l=0,r=n-1,node=1;
prop(node,l,r);
while(l!=r){
int med=(l+r)>>1;
prop(node*2,l,med),prop(node*2+1,med+1,r);
if(!st[node*2])r=med,node*=2;
else l=med+1,node=node*2+1;
}
return (l>=(*lst[x].begin()));
}
int32_t main(){
boost;
//freopen(".in","r",stdin);
int q,cnt=1,t,x,a,b;
cin>>n>>q;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < n; ++j)
cin>>tab[i][j],lst[tab[i][j]].insert(j),pos[tab[i][j]][i]=j;
for (int i = 1; i <= n; ++i)
arr[*lst[i].begin()]--;
for (int i = 0; i < n; ++i)
{
if(i)arr[i]+=arr[i-1];
A[i]=cnt+arr[i];
cnt++;
}
build(1,0,n-1);
while(q--){
cin>>t;
if(t==1){
cin>>x;
if(query(x))cout<<"DA\n";
else cout<<"NE\n";
}
else{
cin>>x>>a>>b;
x--;
update(x,a,b);
}
}
return 0;
}
//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5120 KB |
Output is correct |
2 |
Correct |
4 ms |
5120 KB |
Output is correct |
3 |
Correct |
4 ms |
5120 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
3 ms |
5120 KB |
Output is correct |
6 |
Correct |
3 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5120 KB |
Output is correct |
2 |
Correct |
4 ms |
5120 KB |
Output is correct |
3 |
Correct |
4 ms |
5120 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
3 ms |
5120 KB |
Output is correct |
6 |
Correct |
3 ms |
5120 KB |
Output is correct |
7 |
Correct |
4 ms |
5248 KB |
Output is correct |
8 |
Correct |
4 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5376 KB |
Output is correct |
10 |
Correct |
4 ms |
5376 KB |
Output is correct |
11 |
Correct |
5 ms |
5376 KB |
Output is correct |
12 |
Correct |
4 ms |
5376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5120 KB |
Output is correct |
2 |
Correct |
4 ms |
5120 KB |
Output is correct |
3 |
Correct |
4 ms |
5120 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
3 ms |
5120 KB |
Output is correct |
6 |
Correct |
3 ms |
5120 KB |
Output is correct |
7 |
Correct |
4 ms |
5248 KB |
Output is correct |
8 |
Correct |
4 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5376 KB |
Output is correct |
10 |
Correct |
4 ms |
5376 KB |
Output is correct |
11 |
Correct |
5 ms |
5376 KB |
Output is correct |
12 |
Correct |
4 ms |
5376 KB |
Output is correct |
13 |
Correct |
145 ms |
29260 KB |
Output is correct |
14 |
Correct |
204 ms |
29304 KB |
Output is correct |
15 |
Correct |
197 ms |
29176 KB |
Output is correct |
16 |
Correct |
177 ms |
29060 KB |
Output is correct |
17 |
Correct |
192 ms |
29052 KB |
Output is correct |
18 |
Correct |
196 ms |
29176 KB |
Output is correct |
19 |
Correct |
187 ms |
29048 KB |
Output is correct |
20 |
Correct |
171 ms |
29308 KB |
Output is correct |
21 |
Correct |
194 ms |
29048 KB |
Output is correct |
22 |
Correct |
139 ms |
29304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
30328 KB |
Output is correct |
2 |
Correct |
192 ms |
30184 KB |
Output is correct |
3 |
Correct |
194 ms |
30328 KB |
Output is correct |
4 |
Correct |
182 ms |
30200 KB |
Output is correct |
5 |
Correct |
189 ms |
30456 KB |
Output is correct |
6 |
Correct |
192 ms |
30200 KB |
Output is correct |
7 |
Correct |
206 ms |
30328 KB |
Output is correct |
8 |
Correct |
244 ms |
30200 KB |
Output is correct |
9 |
Correct |
255 ms |
30200 KB |
Output is correct |
10 |
Correct |
187 ms |
30060 KB |
Output is correct |
11 |
Correct |
253 ms |
30328 KB |
Output is correct |
12 |
Correct |
188 ms |
30048 KB |
Output is correct |
13 |
Correct |
250 ms |
30200 KB |
Output is correct |
14 |
Correct |
226 ms |
30200 KB |
Output is correct |
15 |
Correct |
190 ms |
30200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5120 KB |
Output is correct |
2 |
Correct |
4 ms |
5120 KB |
Output is correct |
3 |
Correct |
4 ms |
5120 KB |
Output is correct |
4 |
Correct |
5 ms |
5120 KB |
Output is correct |
5 |
Correct |
3 ms |
5120 KB |
Output is correct |
6 |
Correct |
3 ms |
5120 KB |
Output is correct |
7 |
Correct |
4 ms |
5248 KB |
Output is correct |
8 |
Correct |
4 ms |
5248 KB |
Output is correct |
9 |
Correct |
5 ms |
5376 KB |
Output is correct |
10 |
Correct |
4 ms |
5376 KB |
Output is correct |
11 |
Correct |
5 ms |
5376 KB |
Output is correct |
12 |
Correct |
4 ms |
5376 KB |
Output is correct |
13 |
Correct |
145 ms |
29260 KB |
Output is correct |
14 |
Correct |
204 ms |
29304 KB |
Output is correct |
15 |
Correct |
197 ms |
29176 KB |
Output is correct |
16 |
Correct |
177 ms |
29060 KB |
Output is correct |
17 |
Correct |
192 ms |
29052 KB |
Output is correct |
18 |
Correct |
196 ms |
29176 KB |
Output is correct |
19 |
Correct |
187 ms |
29048 KB |
Output is correct |
20 |
Correct |
171 ms |
29308 KB |
Output is correct |
21 |
Correct |
194 ms |
29048 KB |
Output is correct |
22 |
Correct |
139 ms |
29304 KB |
Output is correct |
23 |
Correct |
197 ms |
30328 KB |
Output is correct |
24 |
Correct |
192 ms |
30184 KB |
Output is correct |
25 |
Correct |
194 ms |
30328 KB |
Output is correct |
26 |
Correct |
182 ms |
30200 KB |
Output is correct |
27 |
Correct |
189 ms |
30456 KB |
Output is correct |
28 |
Correct |
192 ms |
30200 KB |
Output is correct |
29 |
Correct |
206 ms |
30328 KB |
Output is correct |
30 |
Correct |
244 ms |
30200 KB |
Output is correct |
31 |
Correct |
255 ms |
30200 KB |
Output is correct |
32 |
Correct |
187 ms |
30060 KB |
Output is correct |
33 |
Correct |
253 ms |
30328 KB |
Output is correct |
34 |
Correct |
188 ms |
30048 KB |
Output is correct |
35 |
Correct |
250 ms |
30200 KB |
Output is correct |
36 |
Correct |
226 ms |
30200 KB |
Output is correct |
37 |
Correct |
190 ms |
30200 KB |
Output is correct |
38 |
Correct |
287 ms |
32376 KB |
Output is correct |
39 |
Correct |
196 ms |
30200 KB |
Output is correct |
40 |
Correct |
300 ms |
32672 KB |
Output is correct |
41 |
Correct |
209 ms |
30200 KB |
Output is correct |
42 |
Correct |
211 ms |
30456 KB |
Output is correct |
43 |
Correct |
291 ms |
32504 KB |
Output is correct |
44 |
Correct |
202 ms |
30328 KB |
Output is correct |
45 |
Correct |
223 ms |
30328 KB |
Output is correct |
46 |
Correct |
204 ms |
30200 KB |
Output is correct |
47 |
Correct |
203 ms |
30328 KB |
Output is correct |
48 |
Correct |
212 ms |
30328 KB |
Output is correct |
49 |
Correct |
232 ms |
31992 KB |
Output is correct |
50 |
Correct |
224 ms |
30376 KB |
Output is correct |
51 |
Correct |
271 ms |
30456 KB |
Output is correct |
52 |
Correct |
295 ms |
31480 KB |
Output is correct |
53 |
Correct |
227 ms |
30456 KB |
Output is correct |
54 |
Correct |
211 ms |
30328 KB |
Output is correct |
55 |
Correct |
220 ms |
30328 KB |
Output is correct |
56 |
Correct |
256 ms |
30468 KB |
Output is correct |
57 |
Correct |
210 ms |
30456 KB |
Output is correct |
58 |
Correct |
259 ms |
32376 KB |
Output is correct |