Submission #35877886


Source Code Expand

#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

void pow2(int N) {
	int cnt = 0;
	while (N > 1) {
		N /= 2;
		cnt++;
	}
	cout << cnt << endl;
}
int main() {
	int N;
	cin >> N;
	vector<int> A(N+1),ans(2*N+2);
	ans[1] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i <= N; i++) {
		ans[2 * i] = ans[A[i]] + 1;
		ans[2 * i + 1] = ans[A[i]] + 1;
	}
	for (int i = 1; i <= 2 * N + 1; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task C - Ameba
User amaoto
Language C++ (GCC 9.2.1)
Score 300
Code Size 569 Byte
Status AC
Exec Time 655 ms
Memory 5544 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 653 ms 5412 KiB
random_02.txt AC 616 ms 5056 KiB
random_03.txt AC 645 ms 5336 KiB
random_04.txt AC 114 ms 3440 KiB
random_05.txt AC 651 ms 5308 KiB
random_06.txt AC 556 ms 5148 KiB
random_07.txt AC 648 ms 5244 KiB
random_08.txt AC 494 ms 4880 KiB
random_09.txt AC 653 ms 5544 KiB
random_10.txt AC 636 ms 5372 KiB
random_11.txt AC 649 ms 5320 KiB
random_12.txt AC 206 ms 3876 KiB
random_13.txt AC 650 ms 5348 KiB
random_14.txt AC 652 ms 5360 KiB
random_15.txt AC 655 ms 5488 KiB
random_16.txt AC 4 ms 3460 KiB
sample_01.txt AC 2 ms 3288 KiB
sample_02.txt AC 2 ms 3324 KiB