//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
int n,q;
int it[100001][3];
int vis[100001][3];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>q;
for(int i=0;i<n;i++){
cin>>it[i][0];
}
for(int i=0;i<n;i++){
cin>>it[i][1];
}
for(int i=0;i<n;i++){
cin>>it[i][2];
}
while(q--){
int tt;
cin>>tt;
if(tt==1){
int x;
cin>>x;
int st=0;
for(int i=1;i<=n;i++){
for(int j=0;j<3;j++){
vis[i][j]=0;
}
}
set<int> ss;
for(int i=0;i<n;i++){
int kk=1;
for(int j=0;j<3;j++){
ss.erase(it[i][j]);
vis[it[i][j]][j]=1;
if(vis[it[i][j]][0]!=vis[it[i][j]][1] or vis[it[i][j]][0]!=vis[it[i][j]][2]){
ss.insert(it[i][j]);
continue;
}
}
if(vis[x][0]+vis[x][1]+vis[x][2]>0){
kk=0;
break;
}
/*for(int j=1;j<=n;j++){
if(vis[j][0]!=vis[j][1] or vis[j][0]!=vis[j][2]){
kk=0;
break;
}
}*/
/*for(int i=0;i<3;i++){
for(int j=0;j<n;j++){
cout<<vis[j][i]<<",";
}
cout<<endl;
}
cout<<endl;*/
if(ss.size()==0){
st=1;
break;
}
}
if(st==0){
cout<<"DA"<<endl;
}
else{
cout<<"NE"<<endl;
}
}
else{
int x,y,z;
cin>>x>>y>>z;
x--;
int ind=-1;
int ind2=-1;
for(int i=0;i<n;i++){
if(it[i][x]==y){
ind=i;
}
if(it[i][x]==z){
ind2=i;
}
}
//cout<<ind<<":"<<ind2<<endl;
swap(it[ind][x],it[ind2][x]);
}
}
return 0;
}
Compilation message
tenis.cpp: In function 'int main()':
tenis.cpp:42:9: warning: variable 'kk' set but not used [-Wunused-but-set-variable]
42 | int kk=1;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
87 ms |
2796 KB |
Output is correct |
14 |
Correct |
135 ms |
4460 KB |
Output is correct |
15 |
Correct |
36 ms |
4460 KB |
Output is correct |
16 |
Correct |
62 ms |
4332 KB |
Output is correct |
17 |
Correct |
29 ms |
4460 KB |
Output is correct |
18 |
Correct |
34 ms |
4460 KB |
Output is correct |
19 |
Correct |
29 ms |
4332 KB |
Output is correct |
20 |
Correct |
29 ms |
3308 KB |
Output is correct |
21 |
Correct |
30 ms |
4460 KB |
Output is correct |
22 |
Correct |
33 ms |
4460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1067 ms |
2668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
87 ms |
2796 KB |
Output is correct |
14 |
Correct |
135 ms |
4460 KB |
Output is correct |
15 |
Correct |
36 ms |
4460 KB |
Output is correct |
16 |
Correct |
62 ms |
4332 KB |
Output is correct |
17 |
Correct |
29 ms |
4460 KB |
Output is correct |
18 |
Correct |
34 ms |
4460 KB |
Output is correct |
19 |
Correct |
29 ms |
4332 KB |
Output is correct |
20 |
Correct |
29 ms |
3308 KB |
Output is correct |
21 |
Correct |
30 ms |
4460 KB |
Output is correct |
22 |
Correct |
33 ms |
4460 KB |
Output is correct |
23 |
Execution timed out |
1067 ms |
2668 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |