Submission #167344

# Submission time Handle Problem Language Result Execution time Memory
167344 2019-12-07T12:56:38 Z Atill83 Tenis (COI19_tenis) C++14
21 / 100
78 ms 8056 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;
    }
    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

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 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 Correct 70 ms 8056 KB Output is correct
2 Correct 67 ms 6776 KB Output is correct
3 Correct 69 ms 6904 KB Output is correct
4 Correct 70 ms 6652 KB Output is correct
5 Correct 69 ms 7168 KB Output is correct
6 Correct 68 ms 7544 KB Output is correct
7 Correct 66 ms 7544 KB Output is correct
8 Correct 68 ms 7580 KB Output is correct
9 Correct 70 ms 7544 KB Output is correct
10 Correct 70 ms 6568 KB Output is correct
11 Correct 78 ms 7800 KB Output is correct
12 Correct 67 ms 7004 KB Output is correct
13 Correct 67 ms 7416 KB Output is correct
14 Correct 70 ms 7416 KB Output is correct
15 Correct 65 ms 7552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -