이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
void solve(){
ll n , q ,x , y , z;
cin >> n >> q;
int a[3][n + 1];
map<ll,vector<ll>> mp;
for(int i = 0; i< 3 ;i ++){
for(int j = 0; j < n ;j ++){
cin >> a[i][j];
mp[a[i][j]].push_back(j);
}
}
while(q--){
cin >> x;
if(x == 1){
cin >> y;
bool flg = 1;
ll mx1 = 0 , mx2 = 0;
for(int i = 0; i < n ;i ++){
if(a[0][i] == y){
break;
}
mx1 = max(mx1 , mp[a[0][i]][1]);
mx2 = max(mx2 , mp[a[0][i]][2]);
if(mx1 <= i and mx2 <= i){
flg = 0;
break;
}
}
if(flg){
cout << "DA" << '\n';
}
else{
cout << "NE" << '\n';
}
}
else{
cin >> x >> y >> z;
x--;
swap(a[x][mp[y][x]], a[x][mp[z][x]]);
swap(mp[y][x], mp[z][x]);
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tests = 1;
// cin >> tests;
for (int i = 1; i <= tests; i++){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |