Submission #953683

#TimeUsernameProblemLanguageResultExecution timeMemory
953683emad234Gondola (IOI14_gondola)C++17
55 / 100
19 ms3676 KiB
#include "gondola.h" #include <bits/stdc++.h> #define ll long long #define F first #define S second #define pii pair<ll, ll> const ll mod = 1e9 + 9; const ll mxN = 3e5 + 5; using namespace std; int realS[mxN]; int valid(int n, int inputSeq[]) { vector<bool> vis(250000 + 3); int st = 0; int val = 1; for (int i = 0; i < n; i++) { if (vis[inputSeq[i]]) return 0; vis[inputSeq[i]] = 1; if (inputSeq[i] <= n) { st = i; val = inputSeq[i]; } } int og = st; while (1) { st++; val++; if (st >= n) st = 0; if (val > n) val = 1; realS[inputSeq[st]] = val; if (st == og) break; if (inputSeq[st] != val && inputSeq[st] <= n) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { memset(realS, 0, sizeof(realS)); int mx = 0; valid(n, gondolaSeq); for (int i = 0; i < n; i++) mx = max(mx, gondolaSeq[i]); int id = 0; for (int i = n + 1; i <= mx; i++) { if (!realS[i]) { replacementSeq[id] = realS[mx]; realS[mx] = i; } else replacementSeq[id] = realS[i]; id++; } return id; } //---------------------- 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...