이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Self-control leads to consistency.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
template<class T>
bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
ll seg[400011];
ll arr[400011],ari[400011];
void upd(ll p,ll l,ll r,ll k,ll val){
if(l==r && l==k){
seg[p]=max(seg[p],val);
return;
}
ll med=(l+r)>>1;
if(k<=med){
upd(p*2,l,med,k,val);
}
else upd(p*2+1,med+1,r,k,val);
seg[p]=max(seg[p*2],seg[p*2+1]);
}
ll query(ll p,ll l,ll r,ll l1,ll r1){
if(l>r || l>r1 || l1>r)return 0;
if(l>=l1 && r<=r1)return seg[p];
ll med=(l+r)>>1;
return max(query(p*2,l,med,l1,r1),query(p*2+1,med+1,r,l1,r1));
}
int main()
{
//flash;
ll n,q;
cin>>n>>q;
for (ll i = 0; i < n; ++i)
{
ll yo;
cin>>yo;
yo--;
arr[yo]=i;
ari[i]=yo;
upd(1,0,n-1,i,i);
}
for (ll i = 0; i < n; ++i)
{
ll yo;
cin>>yo;
yo--;
upd(1,0,n-1,arr[yo],i);
}
for (ll i = 0; i < n; ++i)
{
ll yo;
cin>>yo;
yo--;
upd(1,0,n-1,arr[yo],i);
}
ll l=0,r=0;
set<ll>ans;
while(query(1,0,n-1,l,r)+1!=(r-l+1)){
ll cur=query(1,0,n-1,l,r);
r++;
}
for (ll i = 0; i <= r; ++i)
{
ans.insert(ari[i]);
}
while(q--){
ll na;
cin>>na;
if(na==1){
ll x;
cin>>x;
x--;
if(ans.find(x)!=ans.end()){
cout<<"DA"<<'\n';
}
else cout<<"NE"<<'\n';
}
else{
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
tenis.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("O3")
tenis.cpp:6:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("unroll-loops")
tenis.cpp: In function 'int main()':
tenis.cpp:82:8: warning: unused variable 'cur' [-Wunused-variable]
ll cur=query(1,0,n-1,l,r);
^~~
tenis.cpp: In function 'void setIO(std::__cxx11::string)':
tenis.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen((s+".in").c_str(),"r",stdin);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tenis.cpp:29:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen((s+".out").c_str(),"w",stdout);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |