Submission #167345

# Submission time Handle Problem Language Result Execution time Memory
167345 2019-12-07T12:57:10 Z Atill83 Tenis (COI19_tenis) C++14
51 / 100
500 ms 7748 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]);
            }
        }

    }


    #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 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 44 ms 5340 KB Output is correct
14 Correct 45 ms 5628 KB Output is correct
15 Correct 43 ms 4856 KB Output is correct
16 Correct 42 ms 4856 KB Output is correct
17 Correct 40 ms 4728 KB Output is correct
18 Correct 42 ms 4668 KB Output is correct
19 Correct 41 ms 4572 KB Output is correct
20 Correct 41 ms 4612 KB Output is correct
21 Correct 39 ms 4856 KB Output is correct
22 Correct 41 ms 5880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 5756 KB Output is correct
2 Correct 64 ms 5328 KB Output is correct
3 Correct 64 ms 5240 KB Output is correct
4 Correct 65 ms 5240 KB Output is correct
5 Correct 64 ms 5240 KB Output is correct
6 Correct 64 ms 5240 KB Output is correct
7 Correct 67 ms 5240 KB Output is correct
8 Correct 67 ms 5372 KB Output is correct
9 Correct 65 ms 5240 KB Output is correct
10 Correct 66 ms 5368 KB Output is correct
11 Correct 67 ms 5496 KB Output is correct
12 Correct 66 ms 5212 KB Output is correct
13 Correct 70 ms 5240 KB Output is correct
14 Correct 68 ms 5316 KB Output is correct
15 Correct 68 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 44 ms 5340 KB Output is correct
14 Correct 45 ms 5628 KB Output is correct
15 Correct 43 ms 4856 KB Output is correct
16 Correct 42 ms 4856 KB Output is correct
17 Correct 40 ms 4728 KB Output is correct
18 Correct 42 ms 4668 KB Output is correct
19 Correct 41 ms 4572 KB Output is correct
20 Correct 41 ms 4612 KB Output is correct
21 Correct 39 ms 4856 KB Output is correct
22 Correct 41 ms 5880 KB Output is correct
23 Correct 66 ms 5756 KB Output is correct
24 Correct 64 ms 5328 KB Output is correct
25 Correct 64 ms 5240 KB Output is correct
26 Correct 65 ms 5240 KB Output is correct
27 Correct 64 ms 5240 KB Output is correct
28 Correct 64 ms 5240 KB Output is correct
29 Correct 67 ms 5240 KB Output is correct
30 Correct 67 ms 5372 KB Output is correct
31 Correct 65 ms 5240 KB Output is correct
32 Correct 66 ms 5368 KB Output is correct
33 Correct 67 ms 5496 KB Output is correct
34 Correct 66 ms 5212 KB Output is correct
35 Correct 70 ms 5240 KB Output is correct
36 Correct 68 ms 5316 KB Output is correct
37 Correct 68 ms 5240 KB Output is correct
38 Execution timed out 1075 ms 7748 KB Time limit exceeded
39 Halted 0 ms 0 KB -