Submission #1015273

#TimeUsernameProblemLanguageResultExecution timeMemory
1015273parsadox2Gondola (IOI14_gondola)C++17
55 / 100
24 ms5664 KiB
#include "gondola.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; int valid(int n, int inputSeq[]) { int mn_pos = 0; for(int i = 1 ; i < n ; i++) if(inputSeq[i] < inputSeq[mn_pos]) mn_pos = i; vector <int> vec; for(int i = mn_pos ; i < n ; i++) vec.push_back(inputSeq[i]); for(int i = 0 ; i < mn_pos ; i++) vec.push_back(inputSeq[i]); set <int> st; for(auto u : vec) st.insert(u); if(st.size() != n) return 0; bool flg = true; for(int i = 1 ; i < n ; i++) if(vec[i] <= n && vec[i] - vec[0] != i) flg = false; return flg; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int mn_pos = 0; for(int i = 1 ; i < n ; i++) if(gondolaSeq[i] < gondolaSeq[mn_pos]) mn_pos = i; vector <int> vec; for(int i = mn_pos ; i < n ; i++) vec.push_back(gondolaSeq[i]); for(int i = 0 ; i < mn_pos ; i++) vec.push_back(gondolaSeq[i]); int mx = 0; for(int i = 0 ; i < n ; i++) mx = max(mx , vec[i]); int l = mx - n , pos = 0 , las = n; vector <pair<int , int>> bad; for(int i = 0 ; i < n ; i++) if(vec[i] > n) bad.push_back(make_pair(vec[i] , i)); if(vec[0] > n) vec[0] = 1; for(int i = 1 ; i < n ; i++) { vec[i] = vec[i - 1] + 1; if(vec[i - 1] == n) vec[i] = 1; } sort(bad.begin() , bad.end()); for(auto u : bad) { while(las < u.F) { las++; replacementSeq[pos] = vec[u.S]; vec[u.S] = las; pos++; } } return l; } int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:21:15: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |  if(st.size() != n)
      |     ~~~~~~~~~~^~~~
#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...