제출 #1237659

#제출 시각아이디문제언어결과실행 시간메모리
1237659hainam2k9Nekameleoni (COCI15_nekameleoni)C++20
140 / 140
427 ms54604 KiB
#include <bits/stdc++.h> #define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0) #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout) #define ll long long #define ull unsigned long long #define i128 __int128 #define db long double #define sz(a) ((int)(a).size()) #define pb emplace_back #define pf emplace_front #define pob pop_back #define pof pop_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define ins emplace #define mp make_pair using namespace std; const int MOD = 1e9+7, MAXN = 1e5+5; const string NAME = ""; int n,q,k,a[MAXN]; int sgt[MAXN<<2]; ll full; vector<pair<ll,int>> pre[MAXN<<2],suf[MAXN<<2]; inline void Merge(int id, int l, int r){ sgt[id]=min(sgt[l],sgt[r]); for(int i=sz(suf[l])-1, j=0; i>=0&&j<sz(pre[r]); --i){ while(j<sz(pre[r])&&(suf[l][i].fi|pre[r][j].fi)!=full) ++j; if(j<sz(pre[r])) sgt[id]=min(sgt[id],pre[r][j].se-suf[l][i].se+1); } pre[id]=pre[l]; for(pair<ll,int>& p : pre[r]) if((pre[id].back().fi|p.fi)!=pre[id].back().fi) pre[id].pb(pre[id].back().fi|p.fi,p.se); suf[id]=suf[r]; for(pair<ll,int>& p : suf[l]) if((suf[id].back().fi|p.fi)!=suf[id].back().fi) suf[id].pb(suf[id].back().fi|p.fi,p.se); } void build(int id, int l, int r){ if(l==r){ if(k==1) sgt[id]=1; pre[id].pb(1ll<<a[l],l), suf[id].pb(1ll<<a[l],l); return; } int mid=(l+r)>>1; build(id<<1,l,mid); build(id<<1|1,mid+1,r); Merge(id,id<<1,id<<1|1); } void update(int id, int l, int r, int pos, int val){ if(pos<l||r<pos) return; if(l==r){ pre[id][0]=suf[id][0]=mp(1ll<<val,pos); return; } int mid=(l+r)>>1; update(id<<1,l,mid,pos,val); update(id<<1|1,mid+1,r,pos,val); Merge(id,id<<1,id<<1|1); } int main() { tt; if(fopen((NAME + ".INP").c_str(), "r")) fo; memset(sgt,0x3f,sizeof(sgt)); cin >> n >> k >> q; for(int i = 1; i<=n; ++i) cin >> a[i], --a[i]; full=(1ll<<k)-1; build(1,1,n); while(q--){ int type,x,y; cin >> type; if(type==1){ cin >> x >> y; update(1,1,n,x,--y); } else cout << (sgt[1]>n ? -1 : sgt[1]) << "\n"; } }

컴파일 시 표준 에러 (stderr) 메시지

nekameleoni.cpp: In function 'int main()':
nekameleoni.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nekameleoni.cpp:64:45: note: in expansion of macro 'fo'
   64 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
nekameleoni.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nekameleoni.cpp:64:45: note: in expansion of macro 'fo'
   64 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...