Submission #48730

#TimeUsernameProblemLanguageResultExecution timeMemory
48730dooweyGondola (IOI14_gondola)C++14
25 / 100
17 ms2148 KiB
#include <bits/stdc++.h> #include "gondola.h" using namespace std; typedef pair<int,int> pii; #define fi first #define se second #define mp make_pair const int N = (int)25e4 + 1293; int valid(int n, int inputSeq[]) { int cnt[N]; for(int j = 0;j < N;j ++ ) cnt[j] = 0; int rest[n]; int maz = (int)4e5 + 12345; for(int i = 0; i < n;i ++){ cnt[inputSeq[i]]++; if(cnt[inputSeq[i]] >= 2) return 0; maz = min(maz, inputSeq[i]); rest[i] = inputSeq[i]; } if(maz > n) return 1; int p,j; for(int i = 0;i < n;i ++ ){ if(rest[i] <= n){ p = rest[i]+1; j = i+1; j %= N; while(p <= n){ rest[j] = p; p++; j++; j%=n; } p = 1; while(p < rest[i]){ rest[j] = p; j++; j %= n; p++; } break; } } for(int i = 0; i < n;i ++){ if(inputSeq[i] <= n){ if(rest[i] != inputSeq[i]) return 0; } } return 1; } //---------------------- int replacement(int n, int gondolas[], int replacementSeq[]) { vector<int>replc; int cnt[N]; for(int i =0;i < N;i ++) cnt[i] = 0; for(int i = 0;i < n;i ++){ if(gondolas[i] > n) replc.push_back(gondolas[i]); cnt[gondolas[i]]++; } sort(replc.begin(),replc.end()); int p = 1; // to cnt array int ii = n + 1; // next broken one int sz = 0; for(auto x : replc){ while(cnt[p] >= 1) p++; replacementSeq[sz] = p; sz++; while(ii < x){ replacementSeq[sz] = ii; sz++; ii++; } p++; } return sz; } //---------------------- 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...