Submission #389219

#TimeUsernameProblemLanguageResultExecution timeMemory
389219Pichon5Gondola (IOI14_gondola)C++17
60 / 100
23 ms2260 KiB
#include "gondola.h" #include<bits/stdc++.h> #define vi vector<int> #define pb push_back #define F first #define S second using namespace std; int valid(int n, int v[]){ vector<int> ck; for(int i=0;i<n;i++){ ck.push_back(v[i]); } sort(ck.begin(),ck.end()); for(int i=1;i<ck.size();i++){ if(ck[i]==ck[i-1]){ return 0; } } int ind=0; for(int i=0;i<n;i++){ if(v[i]<=n){ ind = i-(v[i]-1); if(ind<0){ ind += n; } break; } } int now = 1; for(int i=ind;i<n;i++){ if(v[i]<=n){ if(v[i]!=now){ return 0; } } now++; } for(int i=0;i<ind;i++){ if(v[i]<=n){ if(v[i]!=now){ return 0; } } now++; } return 1; } //---------------------- int replacement(int n, int v[], int R[]) { int pos1=0; for(int i=0;i<n;i++){ if(v[i]<=n){ int B=v[i]-1; if(i-B>=0){ pos1=i-B; }else{ B-=i; pos1=n-B; } break; } } int pos=pos1; vector<pair<int,int> >E;//gondola final y gondola inicial for(int i=1;i<=n;i++){ E.pb({v[pos],i}); pos++; if(pos==n)pos=0; } sort(E.begin(),E.end()); int next=n+1; int res=0; for(int i=0;i<n;i++){ if(E[i].F==E[i].S)continue; R[res]=E[i].S;next++;res++; //cout<<"pongo "<<E[i].S<<endl; int curr=next-1; while(curr!=E[i].F){ //cout<<"pongo "<<curr<<endl; R[res]=curr; curr++;next++;res++; } } //cout<<"respuesta "<<res<<endl; //cout<<endl; return res; } //---------------------- int countReplacement(int n, int v[]){ if(!valid(n,v))return 0; int cant=0,mi=1e9; for(int i=0;i<n;i++){ if(v[i]>n){ cant++; mi=min(mi,v[i]); } } return 1; if(cant==2 && mi==n+2)return 2; return 1; } //number of subtask //n //3 1 4 //5 1 2 3 4 //2 3 4 9 6 7 1

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=1;i<ck.size();i++){
      |              ~^~~~~~~~~~
#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...