Submission #130354

# Submission time Handle Problem Language Result Execution time Memory
130354 2019-07-14T22:41:07 Z thanos Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
611 ms 71288 KB
#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

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:57:7: warning: unused variable 'cnt' [-Wunused-variable]
   int cnt=0;
       ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 565 ms 71060 KB not a zalsequence
2 Incorrect 584 ms 71032 KB not a zalsequence
3 Incorrect 567 ms 71072 KB not a zalsequence
4 Incorrect 577 ms 71060 KB not a zalsequence
5 Incorrect 575 ms 71088 KB not a zalsequence
6 Incorrect 572 ms 71032 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 568 ms 71032 KB Unexpected end of file - int32 expected
2 Incorrect 571 ms 71032 KB Unexpected end of file - int32 expected
3 Incorrect 580 ms 70972 KB Unexpected end of file - int32 expected
4 Incorrect 609 ms 71288 KB Unexpected end of file - int32 expected
5 Incorrect 569 ms 71032 KB Unexpected end of file - int32 expected
6 Incorrect 611 ms 71072 KB Unexpected end of file - int32 expected
7 Incorrect 581 ms 70988 KB Unexpected end of file - int32 expected
8 Incorrect 570 ms 71088 KB Unexpected end of file - int32 expected
9 Incorrect 458 ms 56952 KB Unexpected end of file - int32 expected
10 Incorrect 160 ms 21496 KB Unexpected end of file - int32 expected
11 Incorrect 269 ms 35792 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 292 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 368 KB Unexpected end of file - int32 expected
14 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected