Submission #110509

#TimeUsernameProblemLanguageResultExecution timeMemory
110509MAMBACarnival (CEOI14_carnival)C++17
100 / 100
9 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for (int i = j; i < k; i++) #define pb push_back #define mt make_tuple #define for_all(x) x.begin(),x.end() typedef long long ll; typedef pair<int , int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef long double ld; inline void fileIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } template<class T , class S> inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; } template<class T , class S> inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; } constexpr int N = 150 + 10; constexpr int MOD = 1e9 + 7; template<typename T> inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; } template<typename S, typename T> inline S add(S &l, T r) { return mod(l += r); } ll po(ll v, ll u) { return u ? po(v * v % MOD , u >> 1) * (u & 1 ? v : 1) % MOD : 1; } int n, C, col[N]; vector<int> vec; inline bool query(int l, int r, int id) { cout << r - l + 1 << ' '; rep(i , l , r) cout << vec[i] + 1 << ' '; cout << id + 1 << endl; int res; cin >> res; return res == (r - l + 1); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef LOCAL // fileIO("forbidden1"); #endif cin >> n; rep(i , 0 , n) { if (query(0 , C , i)) { col[i] = C++; vec.pb(i); continue; } int lo = 0, hi = C; while (lo != hi - 1) { int mid = lo + hi >> 1; if (query(lo , mid, i)) lo = mid; else hi = mid; } col[i] = col[vec[lo]]; } cout << 0 << ' '; rep(i , 0 , n) cout << col[i] + 1 << ' '; cout << endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int main()':
carnival.cpp:68:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = lo + hi >> 1;
              ~~~^~~~
#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...