제출 #1090785

#제출 시각아이디문제언어결과실행 시간메모리
1090785PieArmyEditor (BOI15_edi)C++17
15 / 100
64 ms28500 KiB
typedef long long ll; ll pie(ll army){return (1ll<<army);} #include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define endl '\n' #define mid ((left+right)>>1) const ll inf=2000000000000000005; const int sonsuz=2000000005; using namespace std; ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;} const int LO=19; int n; int arr[300001],dep[300001]; int par[300001][LO]; void code(){ cin>>n; for(int i=1;i<=n;i++){ cin>>arr[i]; } set<pair<int,int>>st;st.insert({0,0}); for(int i=1;i<=n;i++){ if(arr[i]>0){ st.insert({-i,arr[i]}); } else{ if(arr[i]==-1){ par[i][0]=-st.begin()->fr; for(int j=1;j<LO;j++){ par[i][j]=par[par[i][j-1]][j-1]; } } else{ int root=i-1; if(arr[root]>arr[i])root=i-1; else{ for(int j=LO-1;j>=1;j--){ if(par[root][j]==0)continue; if(arr[par[root][j]]>arr[i])continue; root=par[root][j]; } root=par[root][1]; } par[i][0]=root; for(int j=1;j<LO;j++){ par[i][j]=par[par[i][j-1]][j-1]; } } dep[i]=dep[par[i][0]]+1; int root=i; for(int j=0;j<LO;j++){ if(dep[i]&pie(j)){ root=par[root][j]; } } if(dep[i]&1)st.erase({-root,arr[root]}); else st.insert({-root,arr[root]}); } cout<<st.begin()->sc<<endl; } } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);} int t=1; if(!t)cin>>t; while(t--){code();cout<<endl;} return 0; }

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

edi.cpp: In function 'int main()':
edi.cpp:69:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~
edi.cpp:69:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...