Submission #12898293


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, A[1 << 16];
int ans[1 << 16];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, 1 << N) cin >> A[i];

	vector<int> cur;
	rep(i, 0, 1 << N) cur.push_back(i);

	rep(round, 1, N + 1) {
		int n = cur.size();

		vector<int> nxt;
		rep(i, 0, n / 2) {
			int a = cur[i * 2];
			int b = cur[i * 2 + 1];

			if (A[a] < A[b]) {
				ans[a] = round;
				nxt.push_back(b);
			}
			else {
				ans[b] = round;
				nxt.push_back(a);
			}
		}
		swap(cur, nxt);
	}

	rep(i, 0, 1 << N) {
		if (ans[i] == 0) ans[i] = N;
		printf("%d\n", ans[i]);
	}
}





Submission Info

Submission Time
Task I - Elimination
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 6
Code Size 1949 Byte
Status
Exec Time 19 ms
Memory 4396 KB

Judge Result

Set Name Score / Max Score Test Cases
All 6 / 6 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
0.txt 2 ms 3748 KB
1.txt 3 ms 3692 KB
10.txt 16 ms 4396 KB
11.txt 18 ms 4316 KB
12.txt 16 ms 4212 KB
13.txt 19 ms 4272 KB
14.txt 17 ms 4268 KB
15.txt 15 ms 4228 KB
16.txt 17 ms 4296 KB
17.txt 18 ms 4292 KB
18.txt 15 ms 4316 KB
19.txt 18 ms 4364 KB
2.txt 4 ms 3584 KB
3.txt 3 ms 3700 KB
4.txt 3 ms 3824 KB
5.txt 2 ms 3628 KB
6.txt 15 ms 4116 KB
7.txt 2 ms 3760 KB
8.txt 2 ms 3644 KB
9.txt 3 ms 3624 KB
s1.txt 2 ms 3732 KB
s2.txt 2 ms 3600 KB
s3.txt 2 ms 3732 KB