제출 #435512

#제출 시각아이디문제언어결과실행 시간메모리
435512Collypso버섯 세기 (IOI20_mushrooms)C++17
25 / 100
33 ms348 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 - 1; i += 2) { int tmp = use_machine({i + 1, 0, i}); if (tmp == 0) ans += 2; else if (tmp == 1) ans += 1; } if (n % 2 == 0) ans += !use_machine({0, n - 1}); return ans; } const int X = 100; int count_mushrooms(int n) { //if (n <= 452) return subtask1(n); vt<int> zeros(1, 0); int q = 1, ans = 1; while(sz(zeros) < X && q < n) { if (use_machine({0, q}) == 0) zeros.pb(q), ans++; q++; } for(int i = 0, to = (n - q + X - 2) / (X - 1); i < to; i++) { vt<int> tmp(1, zeros[0]); for(int j = 1; q < n && j < X; q++, j++) tmp.pb(q), tmp.pb(zeros[j]); ans += sz(tmp) / 2 - use_machine(tmp) / 2; //cout << ans << endl; //for(int x : tmp) cout << x << " "; //cout << endl; //cout << use_machine(tmp) << endl; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...