Submission #274585

#TimeUsernameProblemLanguageResultExecution timeMemory
274585faresbasbsGondola (IOI14_gondola)C++14
55 / 100
51 ms5228 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; int valid(int n, int a[]){ vector<pair<int,int>> v; for(int i = 0 ; i < n ; i += 1){ if(a[i] <= n){ v.push_back({a[i],i}); } } sort(v.begin(),v.end()); for(int i = 1 ; i < v.size() ; i += 1){ int diff1 = v[i].first-v[i-1].first , diff2; if(v[i].second > v[i-1].second){ diff2 = v[i].second-v[i-1].second; }else{ diff2 = n-v[i-1].second+v[i].second; } if(diff1 != diff2){ return 0; } } set<int> st; for(int i = 0 ; i < n ; i += 1){ if(st.count(a[i])){ return 0; } st.insert(a[i]); } return 1; } //---------------------- int replacement(int n, int a[], int replacementSeq[]){ int in[n]; for(int i = 0 ; i < n ; i += 1){ in[i] = i+1; } pair<int,int> v = {-1,-1}; vector<pair<int,int>> g; for(int i = 0 ; i < n ; i += 1){ if(a[i] <= n){ v = {a[i],i}; }else{ g.push_back({a[i],i}); } } if(v.first != -1){ v.second -= v.first-1; if(v.second < 0){ v.second += n; } int cnt = 1; for(int i = v.second ; i < n ; i += 1){ in[i] = cnt; cnt += 1; } for(int i = 0 ; i < v.second ; i += 1){ in[i] = cnt; cnt += 1; } } sort(g.begin(),g.end()); if(g.size() == 0){ return 0; } int p = 0 , cnt = 0; for(int i = n+1 ; i <= g.back().first ; i += 1){ cnt += 1; replacementSeq[i-n-1] = in[g[p].second]; in[g[p].second] = i; if(i == g[p].first){ p += 1; } } return cnt; } //---------------------- int countReplacement(int n, int inputSeq[]){ return -3; }

Compilation message (stderr)

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