Submission #521277

#TimeUsernameProblemLanguageResultExecution timeMemory
521277sofapudenGondola (IOI14_gondola)C++14
5 / 100
1 ms300 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]){ int x = 0; for(int i = 0; i < n; ++i){ if(inputSeq[i] <= n)x = (inputSeq[i]-i+n-1)%(n)+1; } cout << x << '\n'; for(int i = 0; i < n; ++i){ if(inputSeq[i] != (x+i-1)%(n)+1 && inputSeq[i] <= n)return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ vector<pair<int,int>> v; int x = 1; for(int i = 0; i < n; ++i){ if(gondolaSeq[i] <= n)x = (gondolaSeq[i]-i+n-1)%(n)+1; } for(int i = 0; i < n; ++i){ if(gondolaSeq[i] > n){ v.emplace_back((x+i-1)%n+1,gondolaSeq[i]); } } sort(v.begin(),v.end()); int cn = 0; for(int i = 0; i < v.size(); ++i){ replacementSeq[cn++] = v[i].first; while(cn + n < v[i].second){ replacementSeq[cn] = cn+n; cn++; } } return cn; } //---------------------- int countReplacement(int n, int inputSeq[]){ return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i = 0; i < v.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...