Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/detail/standard_policies.hpp>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define pb push_back
- #define F first
- #define S second
- #define ll long long
- #define FILE "t9"
- #define ld long double
- #define endl '\n'
- #define pii pair <int, int>
- #define last fedgfre
- #define ull unsigned long long
- //#define int long long
- //#pragma comment(linker, "/stack:200000000")
- //#pragma GCC optimize("Ofast")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- //#pragma GCC optimize("unroll-loops")
- using namespace std;
- using namespace __gnu_pbds;
- #define kek pair <pii, int>
- typedef tree <kek,null_type,less<kek>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- const int N = 1e5 + 5;
- const ll mod = 998244353;
- const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1 };
- const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1 };
- const ld pi = acos(-1.0);
- const int B = (int)sqrt(N);
- const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
- const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};
- mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
- int a[N];
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- // srand(time(0));
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- // freopen(FILE".in", "r", stdin);
- // freopen(FILE".out", "w", stdout);
- #endif // LOCAL
- int n;
- cin >> n;
- if (n == 1){
- cout << 1;
- return 0;
- }
- vector <pii> q;
- for (int i = 0; i < n; i += 2) {
- q.pb({i, i + 1});
- }
- int cnt = n / 2;
- for (int i = 0; i < n - 1; i++) cin >> a[i];
- int last = 0;
- while (cnt) {
- vector <int> win;
- int it = 0;
- for (int i = last; i < last + cnt; i++) {
- if (a[i] == 1) win.pb(q[it].F);
- else win.pb(q[it].S);
- it++;
- }
- q.clear();
- if (cnt == 1) {
- cout << win[0] + 1;
- return 0;
- }
- for (int i = 0; i < win.size(); i += 2) {
- q.pb({win[i], win[i + 1]});
- }
- last += cnt;
- cnt >>= 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement