제출 #582244

#제출 시각아이디문제언어결과실행 시간메모리
582244drdilyor곤돌라 (IOI14_gondola)C++17
10 / 100
10 ms852 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #ifdef ONPC #include "t_debug.cpp" #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define sz(a) ((int) (a).size()) #define cut(s) {cout << s << '\n'; return 0;} #include "gondola.h" using namespace std; using ll = long long; using vi = vector<int>; namespace pd = __gnu_pbds; template<typename K> using ordered_set = pd::tree<K, pd::null_type, less<K>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>; template<typename... T> using hash_table = pd::gp_hash_table<T...>; const int INF = 1e9; const ll INFL = 1e18; const int N = 250000; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); int valid(int n, int a[]) { int dupe = 0; char visited[N+1]; memset(visited, 0, sizeof(visited)); for (int i = 0; i < n; i++) { if (visited[a[i]]) dupe = 1; visited[a[i]] = 1; } if (dupe) return 0; int fix = -1; for (int i = 0; i < n; i++) { if (a[i] <= n) { fix = i - a[i] + 1; } } if (fix == -1) return 1; for (int i = 1, j = fix; i <= n; i++, j = (j+1)%n) { if (a[j] <= n && a[j] != i) return 0; } return 1; } //---------------------- int replacement(int n, int a_[], int b[]) { if (n > 10) exit(1); vi a(n); for (int i = 0; i < n; i++) a[i] = a_[i]; int fix = -1; for (int i = 0; i < n; i++) { if (a[i] <= n) { fix = i - a[i] + 1; } } vi visited(3*n, -1); int broken = -1; int mx = 0; for (int i = 0; i < n; i++) { if (a[i] > n) { if (i < fix) visited[a[i]] = i + n - fix + 1; else visited[a[i]] = i - fix + 1; } if (a[i] > mx) { mx = a[i]; broken = visited[a[i]]; } } int j = 0; for (int i = n+1; i <= mx; i++) { if (visited[i] == -1) { b[j++] = broken; broken = j + n; } else { b[j++] = visited[i]; } } return j; } //---------------------- 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...