Submission #19724583
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; #define ll long long #define fo(i,n) for(int i=0;i<n;i++) #define pb push_back #define mp make_pair #define F first #define S second #define tr(it,a) for(auto it=a.begin();it!=a.end();it++) typedef pair<int, int> pii; typedef pair<long, long> pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<pair<int, int>> vpii; #define FASTIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL); int main() { FASTIO #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t = 1; // cin >> t; while (t--) { int n; cin >> n; if (n == 1) { cout << 2 << endl; break; } stack < pair<ll, ll>> s1, s2; for (int i = 1; i <= pow(2, n); i++) { ll x; cin >> x; s1.push(mp(x, i)); } for (int i = 0; i < n - 1; i++) { if (i % 2 == 0) { while (!s1.empty()) { auto it1 = s1.top(); s1.pop(); auto it2 = s1.top(); s1.pop(); if (it1.F > it2.F) { s2.push(it1); } else { s2.push(it2); } } } else { while (!s2.empty()) { auto it1 = s2.top(); s2.pop(); auto it2 = s2.top(); s2.pop(); if (it1.F > it2.F) { s1.push(it1); } else { s1.push(it2); } } } } ll ans = 0; while (!s1.empty()) { auto it1 = s1.top(); s1.pop(); auto it2 = s1.top(); s1.pop(); ans = min(it1.S, it2.S); } while (!s2.empty()) { auto it1 = s2.top(); s2.pop(); auto it2 = s2.top(); s2.pop(); ans = min(it1.S, it2.S); } cout << ans << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - ABC Tournament |
User | tushar3010 |
Language | C++ (GCC 9.2.1) |
Score | 0 |
Code Size | 1713 Byte |
Status | WA |
Exec Time | 20 ms |
Memory | 5056 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | extreme_00.txt, handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
extreme_00.txt | AC | 18 ms | 5056 KB |
handmade_00.txt | WA | 2 ms | 3628 KB |
handmade_01.txt | AC | 4 ms | 3580 KB |
random_00.txt | WA | 18 ms | 4940 KB |
random_01.txt | WA | 20 ms | 5000 KB |
random_02.txt | AC | 17 ms | 4936 KB |
random_03.txt | AC | 2 ms | 3948 KB |
random_04.txt | WA | 3 ms | 3832 KB |
random_05.txt | AC | 2 ms | 3832 KB |
sample_01.txt | AC | 3 ms | 3628 KB |
sample_02.txt | AC | 3 ms | 3712 KB |
sample_03.txt | AC | 2 ms | 3964 KB |