Submission #1088581

#TimeUsernameProblemLanguageResultExecution timeMemory
1088581T0p_Gondola (IOI14_gondola)C++14
25 / 100
20 ms2784 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { set<int> st; vector<pair<int, int>> v; for (int i=0 ; i<n ; i++) { if (inputSeq[i] <= n) { v.push_back({ inputSeq[i], i }); } else { if (st.find(inputSeq[i]) != st.end()) { return 0; } st.insert(inputSeq[i]); } } sort(v.begin(), v.end()); int sz_v = v.size(); for (int i=0 ; i<sz_v-1 ; i++) { if (v[i].first == v[i+1].first) { return 0; } if ((v[i].second + v[i+1].first - v[i].first) % n != v[i+1].second) { return 0; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int l = 0; for (int i=0 ; i<n ; i++) { if (gondolaSeq[i] > n) { int prv_i = i == 0 ? n-1 : i-1; replacementSeq[l++] = gondolaSeq[prv_i] == n ? 1 : gondolaSeq[prv_i] + 1; } } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...