//~~~~~~~~~~~~~MJ®™~~~~~~~~~~~~~
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#define rep1(n) for(ll i=0; i<(ll)(n); ++i)
#define rep2(i,n) for(ll i=0; i<(ll)(n); ++i)
#define rep3(i,a,b) for(ll i=(ll)(a); i<(ll)(b); ++i)
#define rep4(i,a,b,c) for(ll i=(ll)(a); i<(ll)(b); i+=(c))
#define cut4(a,b,c,d,e,...) e
#define rep(...) cut4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define per1(n) for(ll i=((ll)n)-1; i>=0; --i)
#define per2(i,n) for(ll i=((ll)n)-1; i>=0; --i)
#define per3(i,a,b) for(ll i=((ll)a)-1; i>=(ll)(b); --i)
#define per4(i,a,b,c) for(ll i=((ll)a)-1; i>=(ll)(b); i-=(c))
#define per(...) cut4(__VA_ARGS__,per4,per3,per2,per1)(__VA_ARGS__)
#define ll long long
#define ln cout<<endl
#define int long long
#define Code ios_base::sync_with_stdio(0);
#define by cin.tie(NULL);
#define Hayan cout.tie(NULL);
#define append push_back
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define vi vector<int>
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define vb vector<bool>
#define vv vector<vi>
#define vp vector<pi>
#define vs vector<string>
#define ul map<int,vi>
#define ub map<int,bool>
#define ui map<int,int>
#define sum(a) accumulate(all(a),0)
#define add insert
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
using namespace std;
const int INF=1e18;
void solve()
{
int n,k,e,x,m,l,r,q,ans=0;
cin>>n>>q;
vv a(3);
vector<ui> idx(3);
rep(j,3)
rep(n){cin>>e;a[j].append(e);idx[j][e]=i;}
rep(q)
{
cin>>e;
if (e==1)
{
cin>>x;
set<int> s;
int ind=1e9,ind2=1e9;
int ind0=idx[0][x];
rep(i,ind0,n)
{
s.insert(a[0][i]);
ind=min(ind,idx[1][a[0][i]]);
ind0=min(ind0,idx[0][a[0][i]]);
ind2=min(ind2,idx[2][a[0][i]]);
}
rep(i,ind+1,n)
{
s.insert(a[1][i]);
ind=min(ind,idx[1][a[1][i]]);
ind0=min(ind0,idx[0][a[1][i]]);
ind2=min(ind,idx[2][a[1][i]]);
}
rep(i,ind2+1,n)
{
s.insert(a[1][i]);
ind=min(ind,idx[1][a[2][i]]);
ind0=min(ind0,idx[0][a[2][i]]);
ind2=min(ind,idx[2][a[2][i]]);
}
rep(i,ind0,n)
{
s.insert(a[0][i]);
ind=min(ind,idx[1][a[0][i]]);
ind0=min(ind0,idx[0][a[0][i]]);
ind2=min(ind2,idx[2][a[0][i]]);
}
rep(i,ind+1,n)
{
s.insert(a[1][i]);
ind=min(ind,idx[1][a[1][i]]);
ind0=min(ind0,idx[0][a[1][i]]);
ind2=min(ind,idx[2][a[1][i]]);
}
rep(i,ind2+1,n)
{
s.insert(a[1][i]);
ind=min(ind,idx[1][a[2][i]]);
ind0=min(ind0,idx[0][a[2][i]]);
ind2=min(ind,idx[2][a[2][i]]);
}
if (s.size()==n)
{
ind=min(ind,idx[1][a[1][i]]);
cout<<"DA"<<endl;
}
else
{
cout<<"NE"<<endl;
}
}
else if (e==2)
{
cin>>k>>l>>r;
swap(idx[k-1][l],idx[k-1][r]);
}
}
// cout<<ans;
// cout<<a.size();
// for (auto i: a){cout<<i<<" ";}
}
signed main(){
Code by Hayan
int ans=1;
//cout<<setprecision(1000);
// cin>>ans;
while(ans--){
// cout << "Case #" << ans << ": \n";
solve();}}
Compilation message
tenis.cpp: In function 'void solve()':
tenis.cpp:108:25: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
108 | if (s.size()==n)
| ~~~~~~~~^~~
tenis.cpp:46:17: warning: unused variable 'm' [-Wunused-variable]
46 | int n,k,e,x,m,l,r,q,ans=0;
| ^
tenis.cpp:46:25: warning: unused variable 'ans' [-Wunused-variable]
46 | int n,k,e,x,m,l,r,q,ans=0;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1050 ms |
26012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |