Submission #587035

#TimeUsernameProblemLanguageResultExecution timeMemory
587035hibikiGondola (IOI14_gondola)C++11
55 / 100
39 ms4556 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() int valid(int n, int a[]) { map<int,bool> use; pair<int,int> mn = {1e9, 1e9}; for(int i = 0; i < n; i++) { mn = min(mn, {a[i], i}); if(use.count(a[i])) return 0; use[a[i]] = true; } if(mn.f > n) return 1; if(mn.f < 1) return 0; for(int i = 0; i < n; i++) { if(a[(mn.s + i) % n] <= n && a[(mn.s + i) % n] != (mn.f + i + n - 1) % n + 1) return 0; } return 1; } //---------------------- int to[250005], use[250005]; int replacement(int n, int a[], int ans[]) { int mx = 0; int cur = -1, idx = 0; pair<int,int> mn = {1e9, 1e9}; for(int i = 0; i < n; i++) mn = min(mn, {a[i], i}), mx = max(mx, a[i]); for(int i = 0; i < n; i++) if(a[(mn.s + i) % n] != (mn.f + i + n - 1) % n + 1) { to[(mn.f + i + n - 1) % n + 1] = a[(mn.s + i) % n]; if(a[(mn.s + i) % n] == mx) cur = (mn.f + i + n - 1) % n + 1; else use[a[(mn.s + i) % n]] = (mn.f + i + n - 1) % n + 1; } for(int i = n + 1; i <= mx; i++) { if(use[i]) ans[idx++] = use[i]; else ans[idx++] = cur, cur = i; } return idx; } //---------------------- 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...