Submission #171719

#TimeUsernameProblemLanguageResultExecution timeMemory
171719gs18103Gondola (IOI14_gondola)C++14
55 / 100
24 ms2800 KiB
#include "gondola.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define em emplace #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int MAX = 101010; const int INF = INT_MAX >> 1; const ll LINF = LLONG_MAX >> 1; int valid(int n, int arr[]) { vector <bool> chk(250050); int idx = -1; for(int i = 0; i < n; i++) { if(arr[i] <= n && idx == -1) { idx = i; } else if(arr[i] <= n) { int temp = arr[idx] + i - idx; temp %= n; if(temp == 0) temp = n; if(temp != arr[i]) return 0; } } sort(arr, arr+n); for(int i = 1; i < n; i++) { if(arr[i] == arr[i-1]) return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int l = 0; vector <int> ori(n, -1); for(int i = 0; i < n; i++) { l = max(gondolaSeq[i] - n, l); if(gondolaSeq[i] <= n && ori[0] == -1) { ori[i] = gondolaSeq[i]; for(int j = 1; j < n; j++) { ori[(i+j)%n] = (ori[i] + j) % n; if(ori[(i+j)%n] == 0) ori[(i+j)%n] = n; } } } if(ori[0] == -1) { for(int i = 0; i < n; i++) ori[i] = i + 1; } vector <pii> temp; for(int i = 0; i < n; i++) { temp.eb(gondolaSeq[i], i); } sort(all(temp)); int idx = 0, last = n + 1; for(int i = 0; i < n; i++) { if(temp[i].fi > n) { replacementSeq[idx++] = ori[temp[i].se]; while(last < temp[i].fi) { replacementSeq[idx++] = last++; } last++; } } 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...