Submission #130354

#TimeUsernameProblemLanguageResultExecution timeMemory
130354thanosZalmoxis (BOI18_zalmoxis)C++14
0 / 100
611 ms71288 KiB
#include<iostream> #include<algorithm> #include<list> #include<vector> using namespace std; int A[1000005]; int N,K; list<int> myl; bool v[1000005]; struct par{ int l; int r; //bool operator<(const par &rhs)const{return rhs.v>v;}; }; list<par> idx; void compress(list<int>::iterator it,list<par>::iterator tt){ list<int>::iterator ap,ab; ap=it; ap++; ab=it; ab--; list<par>::iterator bp,bb; bp=tt; bp++; bb=tt; bb--; while(1){ bool c=false; if(ap!=myl.end() && (*it)==(*ap)){ idx.erase(bp); myl.erase(ap); (*it)++; par r; r.l=(*tt).l; r.r=(*tt).r+1; (*tt)=r; c=true; } if(ab!=myl.begin() && (*it)==(*ab)){ idx.erase(bb); myl.erase(ab); (*it)++; par r; r.l=(*tt).l-1; r.l=(*tt).r; (*tt)=r; c=true; } if(!c) break; ap=it; ap++; ab=it; ab--; bp=tt; bp++; bb=tt; bb--; } } /*void solve(){ vector<list<int>::iterator> myv; list<int>::iterator trace=myl.begin(); trace++; list<par>::iterator indx; indx=idx.begin(); indx++; while(trace!=myl.end()){ } }*/ int main(){ cin>>N>>K; int cnt=0; myl.push_back(0); par e; e.l=0; e.r=0; idx.push_back(e); for(int i=0; i<N; i++){ cin>>A[i]; myl.push_back(A[i]); par t; t.l=i; t.r=i; idx.push_back(t); } list<int>::iterator it=myl.begin(); list<par>::iterator tt=idx.begin(); it++; tt++; while(it!=myl.end()){ compress(it,tt); it++; tt++; } int mn=31; list<int>::iterator find; for(list<int>::iterator it=++myl.begin(); it!=myl.end(); ++it){ if(mn>*(it)){ mn=*it; find=it; } } //void solve(find); int pos=0; list<par>::iterator trace=idx.begin(); trace++; for(list<int>::iterator it=++myl.begin(); it!=myl.end(); it++){ if(*it==mn){ pos=(*trace).r; break; } trace++; } bool c=true; for(int i=0; i<N; i++){ if(i+1==pos && c){ cout<<mn<<" "; i--; c=false; } else{ cout<<A[i]<<" "; c=true; } } /* for(list<int>::iterator it=++myl.begin(); it!=myl.end(); it++){ cout<<*it<<" "; }*/ return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:57:7: warning: unused variable 'cnt' [-Wunused-variable]
   int cnt=0;
       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...