Submission #417719

#TimeUsernameProblemLanguageResultExecution timeMemory
417719vanicGondola (IOI14_gondola)C++14
55 / 100
60 ms5680 KiB
#include "gondola.h" #include <cmath> #include <algorithm> #include <vector> #include <map> #include <cassert> using namespace std; typedef long long ll; const int maxn=1e5+5, mod=1e9+7, Log=30; inline int sum(int a, int b){ if(a+b>=mod){ return a+b-mod; } if(a+b<0){ return a+b+mod; } return a+b; } inline int mul(int a, int b){ return (ll)a*b%mod; } inline int pot(int a, int b){ int sol=1; for(int i=0; i<Log; i++){ if((1<<i)&b){ sol=mul(sol, a); } a=mul(a, a); } return sol; } int poc[maxn]; map < int, int > bio; int valid(int n, int l[]){ for(int i=0; i<n; i++){ if(bio[l[i]]){ return 0; } bio[l[i]]=1; poc[i]=i+1; } bio.clear(); int pos=-1; for(int i=0; i<n; i++){ if(l[i]<=n){ pos=i; break; } } int val=l[pos]; for(int i=0; i<n; i++){ poc[pos]=val; val=(val+1)%n; pos=(pos+1)%n; if(!val){ val=n; } } for(int i=0; i<n; i++){ if(l[i]<=n && poc[i]!=l[i]){ return 0; } } return 1; } int replacement(int n, int l[], int sol[]){ assert(valid(n, l)); int maksi=0, ind; for(int i=0; i<n; i++){ bio[l[i]]=i; if(maksi<l[i]){ maksi=l[i]; ind=i; } } int pos=0; for(int i=n+1; i<=maksi; i++){ if(bio.find(i)!=bio.end()){ sol[pos]=poc[bio[i]]; poc[bio[i]]=i; } else{ sol[pos]=poc[ind]; poc[ind]=i; } pos++; } bio.clear(); return maksi-n; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:94:20: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   94 |    sol[pos]=poc[ind];
      |             ~~~~~~~^
#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...