Submission #953552

#TimeUsernameProblemLanguageResultExecution timeMemory
953552irmuunGondola (IOI14_gondola)C++17
55 / 100
40 ms4672 KiB
#include<bits/stdc++.h> #include "gondola.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int valid(int n, int in[]){ int mn=n+1,pos=-1; map<int,bool>used; for(int i=0;i<n;i++){ if(used[in[i]]){ return 0; } used[in[i]]=true; if(in[i]<=n){ if(in[i]<mn){ mn=in[i]; pos=i; } } } if(pos==-1) return 0; for(int i=0;i<n;i++){ int p=(pos+i)%n; if(in[p]<=n){ if(in[p]!=mn+i) return 0; } } return 1; } int replacement(int n, int gon[], int rep[]){ int mx=0; vector<pair<int,int>>v; int a[n]; iota(a,a+n,1); int mn=n+1,pos=-1; for(int i=0;i<n;i++){ if(gon[i]<=n){ if(gon[i]<mn){ mn=gon[i]; pos=i; } } } if(pos>-1){ for(int i=0;i<n;i++){ a[(i+pos)%n]=mn; mn=mn+1; if(mn>n) mn=1; } } for(int i=0;i<n;i++){ if(gon[i]>n){ v.pb({gon[i],i}); } } sort(all(v)); for(int i=0;i<v.size();i++){ } int l=n+1,cur=0; for(int i=0;i<v.size();i++){ int bef=a[v[i].ss]; for(;l<=v[i].ff;l++){ rep[cur++]=bef; bef=l; } } return cur; } int countReplacement(int n, int in[]){ return 0; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:64:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
gondola.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
gondola.cpp:38:9: warning: unused variable 'mx' [-Wunused-variable]
   38 |     int mx=0;
      |         ^~
#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...