제출 #435383

#제출 시각아이디문제언어결과실행 시간메모리
435383Collypso버섯 세기 (IOI20_mushrooms)C++17
0 / 100
19 ms536 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vt vector #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #pragma GCC optimize ("O3") #pragma GCC optimize ("O2") #define F first #define S second //#define endl '\n' //#define int long long using namespace std; int use_machine(vt<int> x); int subtask1(int n) { int ans = 1; for(int i = 1; i < n; i++) if (use_machine({0, i}) == 0) ans++; return ans; } int group[20007]; int merge_group(int l, int r) { if (r == l) return 0; vt<int> tmp(r - l + 1); for(int i = l; i <= r; i++) tmp[i - l] = i; int val = use_machine(tmp); if (val == r - l) return val; if (val == 0) { for(int i = l + 1; i <= r; i++) group[i] = i - 1; return val; } int m = (l + r) / 2; int val1 = merge_group(l, m); int val2 = merge_group(m + 1, r); if (val1 + val2 == val) group[m + 1] = m; return val; } int count_mushrooms(int n) { if (n <= 227) return subtask1(n); for(int i = 0; i < n; i++) group[i] = i; merge_group(0, n - 1); int sum = 1; for(int i = 1, cur = 1; i < n; i++) { if (group[i] != i - 1) cur = !cur; sum += cur; } //for(int i = 0; i < n; i++) cout << group[i] << " "; //cout << endl; return sum; }
#Verdict Execution timeMemoryGrader output
Fetching results...