Submission #1144803

#TimeUsernameProblemLanguageResultExecution timeMemory
1144803SofiatpcGondola (IOI14_gondola)C++20
55 / 100
24 ms4424 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int inputSeq[]) { set<int> st; int cur = -1; for(int i = 0; i < n; i++){ int x = inputSeq[i]; if(st.find(x) != st.end())return 0; st.insert(x); if(cur == -1 && x <= n){ cur = x+1; if(cur > n)cur = 1; }else if(cur != -1){ if(x <= n && x != cur) return 0; cur++; if(cur > n)cur = 1; } } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector< pair<int,int> > v; int cur = -1, st = -1; for(int i = 0; i < n; i++){ int x = gondolaSeq[i]; if(cur == -1 && x <= n){ st = i; cur = x+1; if(cur > n)cur = 1; }else if(cur != -1){ if(x > n)v.push_back({x,cur}); cur++; if(cur > n)cur = 1; } } if(cur == -1){ st = n; cur = 1; } for(int i = 0; i < st; i++){ int x = gondolaSeq[i]; if(x > n)v.push_back({x,cur}); cur++; if(cur > n)cur = 1; } sort(v.begin(),v.end()); int nxt = n+1, tam = 0; for(int i = 0; i < v.size(); i++){ int og = v[i].second, fim = v[i].first; replacementSeq[tam] = og; tam++; nxt++; while(nxt-1 < fim){ replacementSeq[tam] = nxt-1; tam++; nxt++; } } return tam; } //---------------------- 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...