Submission #594953

#TimeUsernameProblemLanguageResultExecution timeMemory
594953MadokaMagicaFanCounting Mushrooms (IOI20_mushrooms)C++14
80.71 / 100
9 ms604 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int,int>; #define all(v) v.begin(),v.end() #define sort(v) sort(all(v)) #define endl '\n' #define forn(i,n) for(int i = 0; i < n; ++i) #define forbe(i,b,e) for(int i = b; i < e; ++i) #define forr(i,n) for(int i = n-1; i >= 0; --i) #define sz(v) ((int)v.size()) #define pb push_back #define f first #define s second int use_machine(vi x); int count_mushrooms(int n) { vi type(n, 1); vi s(n,1); type[0] = 1; int ans = 1; vi a; vi b; a.pb(0); int pnt = 1; vi ask; int val; while (pnt < n) { ask.clear(); if (sz(a) > sz(b)) { for (pnt; pnt < n && sz(ask) < (sz(a)<<1); ++pnt) { ask.pb(a[sz(ask)>>1]); ask.pb(pnt); } ans += (sz(ask)>>1); val = use_machine(ask); ans -= ((val+1)>>1); if (val&1) b.pb(pnt-1); else a.pb(pnt-1); } else { for (pnt; pnt < n && sz(ask) < (sz(b)<<1); ++pnt) { ask.pb(b[sz(ask)>>1]); ask.pb(pnt); } val = use_machine(ask); ans += ((val+1)>>1); if (val&1) a.pb(pnt-1); else b.pb(pnt-1); } } // while (s[0] < n) { // for (int i = 0; i < n;) { // assert(i+s[i] <= n); // if (i + s[i] == n) // break; // // if (use_machine({i, i + s[i]})) { // forbe(j, i+s[i], i+s[i]+s[i+s[i]]) // type[j] = 1 - type[j]; // } // // s[i] += s[i+s[i]]; // // i += s[i]; // } // } // forn(i, n) // ans += type[i]; // forn(i, n) // cout << type[i] << ' '; // cout << endl; // for(int i = 2; i < n; i+=2) { // ans += 2 - use_machine({i, 0, i-1}); // } // // if ((n&1)==0) // ans += 1 - use_machine({n-1,0}); return ans; } #ifdef ONPC vi rans; int cnt = 0; int use_machine(vi x){ ++ cnt; int _ans = 0; cout << "ASK: "; forn(i , sz(x)) cout << x[i] << ' '; cout << endl; forn(i , sz(x)-1) if (rans[x[i]] != rans[x[i+1]]) ++_ans; cout << "ANSWER: " << _ans << endl; return _ans; } void solve() { int n; cin >> n; rans.resize(n); char c; int ranswer = 0; forn(i, n) { cin >> c; rans[i]=(c=='A'); if (c=='A') ++ranswer; } cout << count_mushrooms(n) << ' ' << ranswer << endl; cout << n << ' ' << cnt << endl; } int main() { // freopen("in", "r", stdin); // ios_base::sync_with_stdio(0);cin.tie(0); solve(); } #endif

Compilation message (stderr)

mushrooms.cpp: In function 'int count_mushrooms(int)':
mushrooms.cpp:41:18: warning: statement has no effect [-Wunused-value]
   41 |             for (pnt; pnt < n && sz(ask) < (sz(a)<<1); ++pnt) {
      |                  ^~~
mushrooms.cpp:54:18: warning: statement has no effect [-Wunused-value]
   54 |             for (pnt; pnt < n && sz(ask) < (sz(b)<<1); ++pnt) {
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...