Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <map>
- #include <iomanip>
- #include <cmath>
- #include <iterator>
- #include <fstream>
- #include <string>
- #include <algorithm>
- #include <set>
- #include <vector>
- #include <valarray>
- #include <queue>
- #define INF 1e18
- //#include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- //freopen("bfs.in", "r", stdin);
- //freopen("bfs.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n,k,x,j;
- cin >>n;
- if (n==1)
- {
- cout <<1;
- return 0;
- }
- vector<int>old,newfag;
- for (int i=0;i<n;i++)
- old.push_back(i+1);
- k=n/2;
- while (k>0)
- {
- j=0;
- for (int i=0;i<k;i++)
- {
- cin >>x;
- if (x==1)newfag.push_back(old[j]);
- else newfag.push_back(old[j+1]);
- j+=2;
- }
- old=newfag;
- newfag.clear();
- k/=2;
- }
- cout <<newfag[0];
- // system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement