# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
167343 |
2019-12-07T12:55:15 Z |
Atill83 |
Tenis (COI19_tenis) |
C++14 |
|
500 ms |
5880 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 >= yer1[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:58: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 |
380 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 |
380 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 |
376 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 |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
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 |
380 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 |
376 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 |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
44 ms |
5376 KB |
Output is correct |
14 |
Correct |
45 ms |
5496 KB |
Output is correct |
15 |
Correct |
41 ms |
4728 KB |
Output is correct |
16 |
Correct |
42 ms |
4856 KB |
Output is correct |
17 |
Correct |
43 ms |
4600 KB |
Output is correct |
18 |
Correct |
42 ms |
4600 KB |
Output is correct |
19 |
Correct |
41 ms |
4600 KB |
Output is correct |
20 |
Correct |
40 ms |
4728 KB |
Output is correct |
21 |
Correct |
41 ms |
4856 KB |
Output is correct |
22 |
Correct |
42 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
5264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
380 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 |
376 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 |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
508 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
44 ms |
5376 KB |
Output is correct |
14 |
Correct |
45 ms |
5496 KB |
Output is correct |
15 |
Correct |
41 ms |
4728 KB |
Output is correct |
16 |
Correct |
42 ms |
4856 KB |
Output is correct |
17 |
Correct |
43 ms |
4600 KB |
Output is correct |
18 |
Correct |
42 ms |
4600 KB |
Output is correct |
19 |
Correct |
41 ms |
4600 KB |
Output is correct |
20 |
Correct |
40 ms |
4728 KB |
Output is correct |
21 |
Correct |
41 ms |
4856 KB |
Output is correct |
22 |
Correct |
42 ms |
5880 KB |
Output is correct |
23 |
Execution timed out |
1066 ms |
5264 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |