제출 #772709

#제출 시각아이디문제언어결과실행 시간메모리
772709cadmiumsky버섯 세기 (IOI20_mushrooms)C++17
80.71 / 100
7 ms448 KiB
#include <bits/stdc++.h>
#include "mushrooms.h"
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

int f(int x) { return (x + 1) / 2; }

int count_mushrooms(int n) {
  int cnt[2] = {1, 0};
  vector<int> known[2];
  known[0].emplace_back(0);
  for(int i = 1; i < n;) {
    int T = (sz(known[0]) > sz(known[1])? 0 : 1);
    vector<int> cquery;
    int j;
    for(j = i; j < n && j - i < sz(known[T]); j++)
      cquery.emplace_back(known[T][j - i]),
      cquery.emplace_back(j);
    i = i + sz(known[T]);
    //cerr << i << ":\n";
    //for(auto x : cquery) cerr << x << ' ';
    int A = use_machine(cquery);
    //cerr << "\n" << A << "\n--\n";
    cnt[T ^ 1] += f(A);
    cnt[T] += sz(cquery) / 2 - f(A);
    
    known[T ^ (A % 2)].emplace_back(cquery.back());
    
  }
  return cnt[0];
}

/**
      Anul asta se da centroid.
-- Surse oficiale
*/

#Verdict Execution timeMemoryGrader output
Fetching results...