답안 #846496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846496 2023-09-07T16:03:03 Z grogu Tenis (COI19_tenis) C++14
100 / 100
167 ms 16820 KB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;

#define maxn 100005
ll n,q;
array<ll,3> a[maxn];
ll c[maxn];
pll t[2*maxn];
ll lazy[2*maxn],ls[2*maxn],rs[2*maxn],tsz = 0,root = 0;
ll rev[3][maxn];
void f(ll i){c[i] = max({a[i][0],a[i][1],a[i][2]});}
void init(ll &v,ll tl,ll tr){
    if(!v) v = ++tsz;
    if(tl==tr){t[v] = {tl,tl};return;}
    ll mid = (tl+tr)/2;
    init(ls[v],tl,mid);
    init(rs[v],mid+1,tr);
    t[v] = min(t[ls[v]],t[rs[v]]);
}
void push(ll v){
    t[v].fi+=lazy[v];
    if(ls[v]) lazy[ls[v]]+=lazy[v];
    if(rs[v]) lazy[rs[v]]+=lazy[v];
    lazy[v] = 0;
}
void upd(ll v,ll tl,ll tr,ll l,ll r,ll x){
    push(v);
    if(l>r||l>tr||tl>r||tl>tr) return;
    if(tl>=l&&tr<=r){lazy[v] = x;push(v);return;}
    ll mid = (tl+tr)/2;
    upd(ls[v],tl,mid,l,r,x);
    upd(rs[v],mid+1,tr,l,r,x);
    t[v] = min(t[ls[v]],t[rs[v]]);
}
void tc(){
    cin >> n >> q;
    for(ll e = 0;e<=2;e++) for(ll i = 1;i<=n;i++){
        cin >> a[i][e];
        rev[e][a[i][e]] = i;
    }
    for(ll e = 0;e<=2;e++) for(ll i = 1;i<=n;i++) a[i][e] = rev[e][i];
    for(ll i = 1;i<=n;i++) f(i);
    init(root,1,n);
    for(ll i = 1;i<=n;i++){
        upd(root,1,n,c[i],n,-1);
    }
    while(q--){
        ll tip; cin >> tip;
        if(tip==1){
            ll i; cin >> i;
            push(root);
            ll x = t[root].sc;
            if(x>=c[i]) cout<<"DA"<<endl;
            else cout<<"NE"<<endl;
        }else{
            ll x,i,j;
            cin >> x >> i >> j;
            x--;
            upd(root,1,n,c[j],n,1);
            upd(root,1,n,c[i],n,1);
            swap(a[i][x],a[j][x]);
            f(i);
            f(j);
            upd(root,1,n,c[j],n,-1);
            upd(root,1,n,c[i],n,-1);
        }
    }
}

int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
	int t; t = 1;
	while(t--){
		tc();
	}
	return (0-0);
}

/**
4 4
1 2 3 4
2 1 3 4
2 4 3 1
1 1
1 4
2 3 1 4
1 4
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8536 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8792 KB Output is correct
10 Correct 2 ms 8536 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8536 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8792 KB Output is correct
10 Correct 2 ms 8536 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 73 ms 15436 KB Output is correct
14 Correct 57 ms 15440 KB Output is correct
15 Correct 57 ms 15452 KB Output is correct
16 Correct 52 ms 15184 KB Output is correct
17 Correct 54 ms 15440 KB Output is correct
18 Correct 53 ms 15440 KB Output is correct
19 Correct 55 ms 15204 KB Output is correct
20 Correct 53 ms 15440 KB Output is correct
21 Correct 54 ms 15252 KB Output is correct
22 Correct 53 ms 15440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 16420 KB Output is correct
2 Correct 69 ms 16464 KB Output is correct
3 Correct 78 ms 16468 KB Output is correct
4 Correct 67 ms 16420 KB Output is correct
5 Correct 69 ms 16288 KB Output is correct
6 Correct 78 ms 16464 KB Output is correct
7 Correct 73 ms 16464 KB Output is correct
8 Correct 67 ms 16464 KB Output is correct
9 Correct 70 ms 16464 KB Output is correct
10 Correct 66 ms 16464 KB Output is correct
11 Correct 80 ms 16464 KB Output is correct
12 Correct 68 ms 16292 KB Output is correct
13 Correct 70 ms 16420 KB Output is correct
14 Correct 79 ms 16464 KB Output is correct
15 Correct 70 ms 16464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 1 ms 8536 KB Output is correct
4 Correct 2 ms 8536 KB Output is correct
5 Correct 1 ms 8536 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 2 ms 8536 KB Output is correct
8 Correct 2 ms 8536 KB Output is correct
9 Correct 2 ms 8792 KB Output is correct
10 Correct 2 ms 8536 KB Output is correct
11 Correct 2 ms 8536 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 73 ms 15436 KB Output is correct
14 Correct 57 ms 15440 KB Output is correct
15 Correct 57 ms 15452 KB Output is correct
16 Correct 52 ms 15184 KB Output is correct
17 Correct 54 ms 15440 KB Output is correct
18 Correct 53 ms 15440 KB Output is correct
19 Correct 55 ms 15204 KB Output is correct
20 Correct 53 ms 15440 KB Output is correct
21 Correct 54 ms 15252 KB Output is correct
22 Correct 53 ms 15440 KB Output is correct
23 Correct 68 ms 16420 KB Output is correct
24 Correct 69 ms 16464 KB Output is correct
25 Correct 78 ms 16468 KB Output is correct
26 Correct 67 ms 16420 KB Output is correct
27 Correct 69 ms 16288 KB Output is correct
28 Correct 78 ms 16464 KB Output is correct
29 Correct 73 ms 16464 KB Output is correct
30 Correct 67 ms 16464 KB Output is correct
31 Correct 70 ms 16464 KB Output is correct
32 Correct 66 ms 16464 KB Output is correct
33 Correct 80 ms 16464 KB Output is correct
34 Correct 68 ms 16292 KB Output is correct
35 Correct 70 ms 16420 KB Output is correct
36 Correct 79 ms 16464 KB Output is correct
37 Correct 70 ms 16464 KB Output is correct
38 Correct 152 ms 16720 KB Output is correct
39 Correct 94 ms 16384 KB Output is correct
40 Correct 161 ms 16720 KB Output is correct
41 Correct 99 ms 16464 KB Output is correct
42 Correct 114 ms 16552 KB Output is correct
43 Correct 167 ms 16720 KB Output is correct
44 Correct 88 ms 16464 KB Output is correct
45 Correct 107 ms 16656 KB Output is correct
46 Correct 88 ms 16464 KB Output is correct
47 Correct 99 ms 16468 KB Output is correct
48 Correct 91 ms 16464 KB Output is correct
49 Correct 106 ms 16464 KB Output is correct
50 Correct 95 ms 16464 KB Output is correct
51 Correct 104 ms 16672 KB Output is correct
52 Correct 158 ms 16812 KB Output is correct
53 Correct 104 ms 16820 KB Output is correct
54 Correct 97 ms 16644 KB Output is correct
55 Correct 106 ms 16720 KB Output is correct
56 Correct 105 ms 16720 KB Output is correct
57 Correct 96 ms 16464 KB Output is correct
58 Correct 123 ms 16680 KB Output is correct