Submission #599428

#TimeUsernameProblemLanguageResultExecution timeMemory
599428AriaHGondola (IOI14_gondola)C++17
55 / 100
21 ms2896 KiB
#include "gondola.h" #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair < int, int > pii; typedef pair < ll, ll > pll; #define F first #define S second #define all(x) x.begin(), x.end() #define SZ(x) (int)x.size() #define Mp make_pair #define endl "\n" #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 1e6 + 10; const int LOG = 20; const ll mod = 1e9 + 7; const ll inf = 8e18; int mark[N]; int valid(int n, int inputSeq[]) { int id = -1; for(int i = 0; i < n; i ++) { if(++ mark[inputSeq[i]] > 1) return 0; if(inputSeq[i] <= n) { id = i; } } if(id == -1) return 1; int start = (id - (inputSeq[id] - 1) + n + n) % n; for(int i = 0; i < n; i ++) { int j = (i + start) % n; if(inputSeq[j] > n) continue; if(inputSeq[j] != i + 1) { return 0; } } return 1; } //---------------------- int replacement(int n, int A[], int replacementSeq[]) { int Mx = 0; int id = -1; for(int i = 0; i < n; i ++) { Mx = max(Mx, A[i]); mark[A[i]] ++; if(A[i] <= n) { id = i; } } vector < int > vec; vec.push_back(Mx); for(int i = Mx - 1; i > n; i --) { if(mark[i] > 2) return -1; if(mark[i] == 0) vec.push_back(i); } int start; if(id == -1) { start = 0; } else { start = (id - (A[id] - 1) + n + n) % n; } for(int i = 0; i < n; i ++) { int j = (start + i) % n; if(A[j] <= n) continue; ///printf("i = %d j = %d\n", i, j); if(A[j] != Mx) replacementSeq[A[j] - n - 1] = i + 1; else { ///printf("here i = %d j = %d\n", i, j); int last = i + 1; while(SZ(vec)) { int l = vec.back(); ///printf("here l = %d last = %d\n", l, last); vec.pop_back(); replacementSeq[l - n - 1] = last; last = l; } } } int sz = 0; return Mx - n; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:98:7: warning: unused variable 'sz' [-Wunused-variable]
   98 |   int sz = 0;
      |       ^~
#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...