# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
548565 |
2022-04-13T20:03:06 Z |
leaked |
Tenis (COI19_tenis) |
C++17 |
|
190 ms |
8200 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define m_p make_pair
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pw(x) (1LL<<(x))
#define fast_prep ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//#define int long long
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const int N=1e5+1;
int t[4*N],p[4*N];
void push(int v,int tl,int tr){
if(tl==tr||!p[v])
return;
for(auto &u : {2*v,2*v+1})
p[u]+=p[v],t[u]+=p[v];
p[v]=0;
}
void add(int l,int r,int x,int v,int tl,int tr){
if(tl>=l&&tr<=r){
t[v]+=x;p[v]+=x;
return;
}
if(tl>r||tr<l)
return;
int tm=(tl+tr)>>1;push(v,tl,tr);
add(l,r,x,2*v,tl,tm);add(l,r,x,2*v+1,tm+1,tr);
t[v]=min(t[2*v],t[2*v+1]);
}
int get(int l,int r,int v,int tl,int tr){
if(tl>=l&&tr<=r)
return t[v];
if(tl>r||tr<l)
return 1e9;
int tm=(tl+tr)>>1;push(v,tl,tr);
return min(get(l,r,2*v,tl,tm),get(l,r,2*v+1,tm+1,tr));
}
signed main(){
fast_prep;
int n,q;
cin>>n>>q;
vec<vec<int>>p(3,vec<int>(n));
vec<vec<int>>ord(3,vec<int>(n));
for(int i=0;i<3;i++){
for(auto &z : p[i])
cin>>z,--z;
for(int j=0;j<n;j++) ord[i][p[i][j]]=j;
}
for(int i=0;i<n;i++) add(0,i,1,1,0,n-1);
auto eval=[&](int i){
return min({ord[0][i],ord[1][i],ord[2][i]});
};
for(int i=0;i<n;i++){
add(0,eval(i),-1,1,0,n-1);
}
while(q--){
int tp;
cin>>tp;
if(tp==1){
int x;
cin>>x;
--x;
int j=eval(x);
cout<<(get(1,j,1,0,n-1)==0?"NE":"DA")<<'\n';
}
else{
int k,i,j;
cin>>k>>i>>j;--i;--j;--k;
add(0,eval(i),1,1,0,n-1);add(0,eval(j),1,1,0,n-1);
swap(ord[k][i],ord[k][j]);
add(0,eval(i),-1,1,0,n-1);add(0,eval(j),-1,1,0,n-1);
}
}
return 0;
}
/*
abbaaa
cbbbbccbbccbbbbbbc
(((((((()))())))))
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
76 ms |
6932 KB |
Output is correct |
14 |
Correct |
64 ms |
6852 KB |
Output is correct |
15 |
Correct |
65 ms |
6724 KB |
Output is correct |
16 |
Correct |
86 ms |
6812 KB |
Output is correct |
17 |
Correct |
68 ms |
6836 KB |
Output is correct |
18 |
Correct |
68 ms |
6856 KB |
Output is correct |
19 |
Correct |
69 ms |
6744 KB |
Output is correct |
20 |
Correct |
86 ms |
6892 KB |
Output is correct |
21 |
Correct |
70 ms |
6836 KB |
Output is correct |
22 |
Correct |
82 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
7996 KB |
Output is correct |
2 |
Correct |
128 ms |
7848 KB |
Output is correct |
3 |
Correct |
128 ms |
7796 KB |
Output is correct |
4 |
Correct |
127 ms |
7924 KB |
Output is correct |
5 |
Correct |
115 ms |
7796 KB |
Output is correct |
6 |
Correct |
125 ms |
7840 KB |
Output is correct |
7 |
Correct |
129 ms |
7884 KB |
Output is correct |
8 |
Correct |
129 ms |
7812 KB |
Output is correct |
9 |
Correct |
118 ms |
7800 KB |
Output is correct |
10 |
Correct |
118 ms |
7852 KB |
Output is correct |
11 |
Correct |
114 ms |
8044 KB |
Output is correct |
12 |
Correct |
114 ms |
7776 KB |
Output is correct |
13 |
Correct |
149 ms |
7892 KB |
Output is correct |
14 |
Correct |
134 ms |
7868 KB |
Output is correct |
15 |
Correct |
147 ms |
7848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
76 ms |
6932 KB |
Output is correct |
14 |
Correct |
64 ms |
6852 KB |
Output is correct |
15 |
Correct |
65 ms |
6724 KB |
Output is correct |
16 |
Correct |
86 ms |
6812 KB |
Output is correct |
17 |
Correct |
68 ms |
6836 KB |
Output is correct |
18 |
Correct |
68 ms |
6856 KB |
Output is correct |
19 |
Correct |
69 ms |
6744 KB |
Output is correct |
20 |
Correct |
86 ms |
6892 KB |
Output is correct |
21 |
Correct |
70 ms |
6836 KB |
Output is correct |
22 |
Correct |
82 ms |
6744 KB |
Output is correct |
23 |
Correct |
120 ms |
7996 KB |
Output is correct |
24 |
Correct |
128 ms |
7848 KB |
Output is correct |
25 |
Correct |
128 ms |
7796 KB |
Output is correct |
26 |
Correct |
127 ms |
7924 KB |
Output is correct |
27 |
Correct |
115 ms |
7796 KB |
Output is correct |
28 |
Correct |
125 ms |
7840 KB |
Output is correct |
29 |
Correct |
129 ms |
7884 KB |
Output is correct |
30 |
Correct |
129 ms |
7812 KB |
Output is correct |
31 |
Correct |
118 ms |
7800 KB |
Output is correct |
32 |
Correct |
118 ms |
7852 KB |
Output is correct |
33 |
Correct |
114 ms |
8044 KB |
Output is correct |
34 |
Correct |
114 ms |
7776 KB |
Output is correct |
35 |
Correct |
149 ms |
7892 KB |
Output is correct |
36 |
Correct |
134 ms |
7868 KB |
Output is correct |
37 |
Correct |
147 ms |
7848 KB |
Output is correct |
38 |
Correct |
162 ms |
8172 KB |
Output is correct |
39 |
Correct |
145 ms |
8020 KB |
Output is correct |
40 |
Correct |
190 ms |
8136 KB |
Output is correct |
41 |
Correct |
129 ms |
8028 KB |
Output is correct |
42 |
Correct |
165 ms |
8068 KB |
Output is correct |
43 |
Correct |
170 ms |
8132 KB |
Output is correct |
44 |
Correct |
141 ms |
8016 KB |
Output is correct |
45 |
Correct |
158 ms |
8040 KB |
Output is correct |
46 |
Correct |
128 ms |
7984 KB |
Output is correct |
47 |
Correct |
151 ms |
8012 KB |
Output is correct |
48 |
Correct |
138 ms |
7880 KB |
Output is correct |
49 |
Correct |
181 ms |
8000 KB |
Output is correct |
50 |
Correct |
141 ms |
7924 KB |
Output is correct |
51 |
Correct |
143 ms |
8052 KB |
Output is correct |
52 |
Correct |
164 ms |
8200 KB |
Output is correct |
53 |
Correct |
151 ms |
8064 KB |
Output is correct |
54 |
Correct |
147 ms |
8136 KB |
Output is correct |
55 |
Correct |
132 ms |
7972 KB |
Output is correct |
56 |
Correct |
129 ms |
8084 KB |
Output is correct |
57 |
Correct |
146 ms |
7952 KB |
Output is correct |
58 |
Correct |
138 ms |
8060 KB |
Output is correct |