Submission #167344

#TimeUsernameProblemLanguageResultExecution timeMemory
167344Atill83Tenis (COI19_tenis)C++14
21 / 100
78 ms8056 KiB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, q;
int a[MAXN], hash1[MAXN], b[MAXN], hash2[MAXN], c[MAXN], hash3[MAXN];
ll tp[MAXN], yer1[MAXN], yer2[MAXN], yer3[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>q;

    for(int i = 1; i <= n; i++){
        cin>>a[i];
        yer1[a[i]] = i;
    }
    tp[0] = 1;
    for(int i = 1; i <= n; i++){
        cin>>b[i];
        yer2[b[i]] = i;
        tp[i] = tp[i - 1]*2%mod;
    }
    for(int i = 1; i <= n; i++){
        cin>>c[i];
        yer3[c[i]] = i;
    }
    bool deg = 0;
    
    int yer;
    while(q--){
        int type;
        cin>>type;
        if(type == 1){
            int x;
            cin>>x;
            if(deg == 0){
                for(int i = 1; i <= n; i++){
                    hash1[i] = (hash1[i - 1] + tp[a[i]])%mod;
                    hash2[i] = (hash2[i - 1] + tp[b[i]])%mod;
                    hash3[i] = (hash3[i - 1] + tp[c[i]])%mod;
                    if(hash1[i] == hash2[i] && hash2[i] == hash3[i]){
                        yer = i;
                        break;
                    }
                }
                deg = 1;
            }
            cout<<(yer >= yer1[x] ? "DA" : "NE")<<endl;
        }else{
            deg = 0;
            int court, l, r;
            cin>>court>>l>>r;
            if(court == 1){
                swap(a[yer1[l]], a[yer1[r]]);
                swap(yer1[l], yer1[r]);
            }else if(court == 2){
                swap(b[yer2[l]], b[yer2[r]]);
                swap(yer2[l], yer2[r]);
            }else{
                swap(c[yer3[l]], c[yer3[r]]);
                swap(yer3[l], yer3[r]);
            }
            deg = 1;
        }

    }


    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message (stderr)

tenis.cpp: In function 'int main()':
tenis.cpp:63:24: warning: 'yer' may be used uninitialized in this function [-Wmaybe-uninitialized]
             cout<<(yer >= yer1[x] ? "DA" : "NE")<<endl;
                    ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...