Submission #999084


Source Code Expand

#include "iostream"
#include "math.h"
using namespace std;

int N;
int hard[300000];
bool flag[300000];
int f;

int main() {
	cin >> N;
	for (int i = 0; i < pow(2, N); i++) {
		cin >> hard[i];
		flag[i] = true;
	}
	f = -1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < pow(2, N); j++) {
			if (flag[j]) {
				if (f == -1) {
					f = j;
				}
				else {
					if (hard[f] == hard[j]) {
						flag[f] = false;
					}
					else if (hard[f] > hard[j]) {
						flag[j] = false;
						hard[f] -= hard[j];
					}
					else {
						flag[f] = false;
						hard[j] -= hard[f];
					}
					f = -1;
				}
			}
		}
	}
	for (int i = 0; i < pow(2, N); i++) {
		if (flag[i]) {
			cout << hard[i] << "\n";
		}
	}
	return 0;
}

Submission Info

Submission Time
Task C - Kode Festival
User olphe
Language C++14 (GCC 5.4.1)
Score 100
Code Size 759 Byte
Status AC
Exec Time 460 ms
Memory 1536 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt
Case Name Status Exec Time Memory
sample_01.txt AC 4 ms 512 KB
sample_02.txt AC 2 ms 256 KB
subtask1_01.txt AC 2 ms 256 KB
subtask1_02.txt AC 3 ms 256 KB
subtask1_03.txt AC 3 ms 256 KB
subtask1_04.txt AC 3 ms 256 KB
subtask1_05.txt AC 27 ms 384 KB
subtask1_06.txt AC 2 ms 256 KB
subtask1_07.txt AC 53 ms 384 KB
subtask1_08.txt AC 222 ms 896 KB
subtask1_09.txt AC 4 ms 256 KB
subtask1_10.txt AC 459 ms 1536 KB
subtask1_11.txt AC 460 ms 1536 KB
subtask1_12.txt AC 459 ms 1536 KB
subtask1_13.txt AC 459 ms 1536 KB
subtask1_14.txt AC 460 ms 1536 KB
subtask1_15.txt AC 459 ms 1536 KB
subtask1_16.txt AC 459 ms 1536 KB
subtask1_17.txt AC 459 ms 1536 KB
subtask1_18.txt AC 460 ms 1536 KB
subtask1_19.txt AC 460 ms 1536 KB