#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<vector<int>> data(3,vector<int>(100005));
vector<vector<int>> arr(3);
vector<int> P(3,0);
bool check(int x){
for(int k=0;k<3;k++){
for(int l=0;l<3;l++){
if(data[k][x]<data[k][P[l]])return true;
}
}
return false;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int n,q;
cin>>n>>q;
for(int k=0;k<3;k++)
for(int i=0;i<n;i++){
int x;
cin>>x;
arr[k].pb(x);
data[k][x]=i;
if(i==0)P[k]=x;
}
while(q--){
int k;
cin>>k;
if(k==1){
int x;
cin>>x;
bool yes=false;
if(find(all(P),x)!=P.end())yes=true;
for(int i=0;i<3&&yes==false;i++){
for(int j=data[i][x]+1;j<n&&yes==false;j++){
if(check(arr[i][j]))yes=true;
}
}
if(yes)cout<<"DA\n";
else cout<<"NE\n";
}
else{
int p,x,y;
cin>>p>>x>>y;p--;
swap(arr[p][data[p][x]],arr[p][data[p][y]]);
if(P[p]==x)P[p]=y;
else if(P[p]==y)P[p]=x;
swap(data[p][x],data[p][y]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
7968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3448 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |