Submission #765663

#TimeUsernameProblemLanguageResultExecution timeMemory
765663marvinthangSimurgh (IOI17_simurgh)C++17
Compilation error
0 ms0 KiB
/************************************* * author: marvinthang * * created: 25.06.2023 08:50:11 * *************************************/ #include "prize.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define left ___left #define right ___right #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define MASK(i) (1LL << (i)) #define BIT(x, i) ((x) >> (i) & 1) #define __builtin_popcount __builtin_popcountll #define ALL(v) (v).begin(), (v).end() #define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define REPD(i, n) for (int i = (n); i--; ) #define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; ++i) #define FORD(i, b, a) for (int i = (b), _a = (a); --i >= _a; ) #define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORDE(i, b, a) for (int i = (b), _a = (a); i >= _a; --i) #define scan_op(...) istream & operator >> (istream &in, __VA_ARGS__ &u) #define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u) #ifdef LOCAL #include "debug.h" #else #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } #define DB(...) 23 #define db(...) 23 #define debug(...) 23 #endif template <class U, class V> scan_op(pair <U, V>) { return in >> u.first >> u.second; } template <class T> scan_op(vector <T>) { for (size_t i = 0; i < u.size(); ++i) in >> u[i]; return in; } template <class U, class V> print_op(pair <U, V>) { return out << '(' << u.first << ", " << u.second << ')'; } template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")"; else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); } template <class ...U> print_op(tuple<U...>) { return print_tuple_utils<0, tuple<U...>>(out, u); } template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream&>::type operator << (ostream &out, const Con &con) { out << '{'; for (__typeof(con.begin()) it = con.begin(); it != con.end(); ++it) out << (it == con.begin() ? "" : ", ") << *it; return out << '}'; } template <class A, class B> bool minimize(A &a, B b) { if (a > b) { a = b; return true; } return false; } template <class A, class B> bool maximize(A &a, B b) { if (a < b) { a = b; return true; } return false; } // end of template mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <class T> T rand(T l, T h) { return uniform_int_distribution <T> (l, h) (rng); } template <class T> T rand(T h) { return uniform_int_distribution <T> (0, h - 1) (rng); } int find_best(int n) { int cnt = 0; int ma = 0; vector <vector <int>> res(n); auto ASK = [&] (int i) { if (res[i].empty()) res[i] = ask(i); return res[i]; }; REP(t, 10) { int i = rand(n); vector <int> a = ASK(i); if (!a[0] && !a[1]) return i; maximize(ma, a[0] + a[1]); } priority_queue <int, vector <int>, greater <int>> pq; REP(i, n) if (!res[i].empty() && res[i][0] + res[i][1] < ma) pq.push(i); pq.push(n); for (int i = 0; i < n; ) { while (pq.top() < i) pq.pop(); int l = i, r = pq.top() - 1; while (l <= r) { int m = l + r >> 1; vector <int> a = ASK(m); if (a[0] + a[1] < ma) { r = m - 1; pq.push(m); } else { if (a[0] == cnt) l = m + 1; else r = m - 1; } } while (++r < n) { vector <int> a = ASK(r); if (a[0] + a[1] == ma) break; ++cnt; if (!a[0] && !a[1]) return r; } i = r; } return -1; } #ifdef LOCAL #include "prize.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; static const int max_q = 10000; static int n; static int query_count = 0; static vector<int> g; static vector<vector<int> > rank_count; vector<int> ask(int i) { query_count++; if(query_count > max_q) { cerr << "Query limit exceeded" << endl; exit(0); } if(i < 0 || i >= n) { cerr << "Bad index: " << i << endl; exit(0); } vector<int> res(2); res[0] = rank_count[g[i] - 1][i + 1]; res[1] = rank_count[g[i] - 1][n] - res[0]; return res; } int main() { file("prize"); cin >> n; g.resize(n); for(int i = 0; i < n; i++) { cin >> g[i]; if(g[i] < 1) { cerr << "Invalid rank " << g[i] << " at index " << i << endl; exit(0); } } int max_rank = *max_element(g.begin(), g.end()); rank_count.resize(max_rank + 1, vector<int>(n + 1, 0)); for(int r = 0; r <= max_rank; r++) { for(int i = 1; i <= n; i++) { rank_count[r][i] = rank_count[r][i - 1]; if(g[i - 1] == r) rank_count[r][i]++; } } for(int i = 0; i <= n; i++) for(int r = 1; r <= max_rank; r++) rank_count[r][i] += rank_count[r - 1][i]; int res = find_best(n); cout << res << endl << "Query count: " << query_count << endl; return 0; } #endif

Compilation message (stderr)

simurgh.cpp:6:10: fatal error: prize.h: No such file or directory
    6 | #include "prize.h"
      |          ^~~~~~~~~
compilation terminated.