Submission #144284

# Submission time Handle Problem Language Result Execution time Memory
144284 2019-08-16T13:49:06 Z Abelyan Tenis (COI19_tenis) C++17
0 / 100
360 ms 6536 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa

const int N=2e5+10;
const ll MOD2=998244353;
const ll MOD=1e9+7;

void yes(){
    cout<<"DA"<<endl;
}
void no(){
    cout<<"NE"<<endl;
}
pir operator +(pir a,int k){return {a.fr+k,a.sc};}
void operator +=(pir &a,int k){a.fr+=k;}
pir sg[4*N];
int lazy[4*N];

void build(int v,int tl,int tr){
    if (tl==tr){
        sg[v]={tl,tl};
        return;
    }
    int tm=(tl+tr)/2;
    build(v+v,tl,tm);
    build(v+v+1,tm+1,tr);
    sg[v]=min(sg[v+v],sg[v+v+1]);
}

void update(int v,int tl,int tr,int l,int r,int del){
    if (l>r)return;
    if (tl==l && tr==r){
        lazy[v]+=del;
        sg[v]+=del;
        return;
    }
    int tm=(tl+tr)/2;
    update(v+v,tl,tm,l,min(r,tm),del);
    update(v+v+1,tm+1,tr,max(l,tm+1),r,del);
    sg[v]=min(sg[v+v],sg[v+v+1])+lazy[v];
}


int a[3][N],ind[3][N],mx[N];

void upd(int v){
    mx[v]=max(ind[0][v],max(ind[1][v],ind[2][v]));
}

int main(){
    fastio;
    srng;
    int n,q;
    cin>>n>>q;
    build(1,0,n-1);
    FOR(i,3)
        FORD(j,n){

            cin>>a[i][j];
            //ad(1,0,n-1,j,i,a[i][j]);
            ind[i][a[i][j]]=j;
        }
    FORT(i,1,n){
        upd(i);
        update(1,0,n-1,mx[i],n-1,1);
    }
    FOR(i,q){
        int tp;
        cin>>tp;
        if (tp==1){
            int x;
            cin>>x;
            //cout<<query(1,0,n-1)<<endl;
            if (ind[0][x]<=sg[1].sc && sg[1].fr==0)yes();
            else no();
        }
        else{
            int tp,v,u;
            cin>>tp>>v>>u;
            tp--;
            update(1,0,n-1,mx[v],n-1,-1);
            update(1,0,n-1,mx[u],n-1,-1);
            swap(ind[tp][v],ind[tp][u]);
            upd(v);
            upd(u);
            update(1,0,n-1,mx[v],n-1,1);
            update(1,0,n-1,mx[u],n-1,1);
        }
    }
    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 360 ms 6536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -