Submission #599250

#TimeUsernameProblemLanguageResultExecution timeMemory
599250Koosha_mvGondola (IOI14_gondola)C++14
55 / 100
21 ms2260 KiB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e5+99;

int mark[N];

int valid(int n, int inputSeq[]){
  f(i,0,n) inputSeq[i]--;
  f(i,0,n) if(++mark[inputSeq[i]]>1) return 0;
  f(i,0,n){
    if(inputSeq[i]<n){
      f(j,0,n){
        if(inputSeq[(i+j)%n]!=(inputSeq[i]+j)%n && inputSeq[(i+j)%n]<n) return 0;
      }
      return 1;
    }
  }
  return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
  vector<pair<int,int>> vec;
  f(i,0,n) gondolaSeq[i]--;
  int b=0,l=0;
  f(i,0,n){
    if(gondolaSeq[i]<n){
      b=1;
      f(j,0,n){
        if(gondolaSeq[(i+j)%n]>=n){
          vec.pb(mp(gondolaSeq[(i+j)%n],(gondolaSeq[i]+j)%n));
        }
      }
      break ;
    }
  }
  if(b==0){
    f(i,0,n){
      vec.pb({gondolaSeq[i],i});
    }
  }
  sort(all(vec));
  int prv=n-1;
  for(auto p : vec){
    //erorp(p);
    replacementSeq[l++]=p.S;
    //eror(p.S);
    f(i,prv+1,p.F) replacementSeq[l++]=i;
    prv=p.F;
  }
  f(i,0,l){
    replacementSeq[i]++;
  }
  //dbga(replacementSeq,0,l);
  return l;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
#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...