Submission #167341

# Submission time Handle Problem Language Result Execution time Memory
167341 2019-12-07T12:52:17 Z Atill83 Tenis (COI19_tenis) C++14
0 / 100
500 ms 7200 KB
#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;
    }
    while(q--){
        int type;
        cin>>type;
        if(type == 1){
            int x;
            cin>>x;
            int yer;
            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;
                }
            }
            cout<<(yer >= x ? "DA" : "NE")<<endl;
        }else{
            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]);
            }
        }

    }


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

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:4:14: warning: 'yer' may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define endl '\n'
              ^~~~
tenis.cpp:48:17: note: 'yer' was declared here
             int yer;
                 ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 7200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -