CSES - Datatähti 2016 alku - Results
Submission details
Task:Kirjat
Sender:while(false)
Submission time:2015-09-29 17:27:45
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:44:7: error: expected ';' before ':' token
    j++:
       ^

Code

#include <iostream>

using namespace std;

int AoB = 0;
int * list1;
int * list2;
bool * booksListed;

int main() {
	cin >> AoB;
	list1 = new int[AoB];
	list2 = new int[AoB];
	booksListed = new bool[AoB];
	for (int i = 0; i < AoB; i++) {
		cin >> list1[i];
		booksListed[i] = false;
	}
	for (int i = 0; i < AoB; i++) {
		cin >> list2[i];
	}
	//a
	for (int i = 0; i < AoB-4; i++) {
		bool bookNotFound = true;
		int k = 1;
		while (bookNotFound) {
			if (!booksListed[k - 1] && list1[i] != k && list2[i] != k) {
				booksListed[k - 1] = true;
				cout << k << ' ';
				bookNotFound = false;
			}
			k++;
			if (k > AoB) { return 1; }
		}
	}
	//b
	int MB[] = { 0,0,0,0 };//missing books
	bool MBListed[] = {false,false,false,false};//missing books listed
	int FB[] = { 0,0,0,0 };//found books
	int j = 0;
	for (int i = 0; i < AoB; i++) {
		if (!booksListed[i]) {
			MB[j] = i+1;
			j++:
		}
	}
	bool last4NotFound = true;
	for (int k = 0; k < 4 && last4NotFound; k++) {
		if (MB[k] != list1[AoB - 4] && MB[k] != list2[AoB - 4] && !MBListed[k]) {
			FB[0] = MB[k];
			MBListed[k] = true;
			for (int k = 0; k < 4 && last4NotFound; k++) {
				if (MB[k] != list1[AoB - 3] && MB[k] != list2[AoB - 3] && !MBListed[k]) {
					FB[1] = MB[k];
					MBListed[k] = true;
					for (int k = 0; k < 4 && last4NotFound; k++) {
						if (MB[k] != list1[AoB - 2] && MB[k] != list2[AoB - 2] && !MBListed[k]) {
							FB[2] = MB[k];
							MBListed[k] = true;
							for (int k = 0; k < 4 && last4NotFound; k++) {
								if (MB[k] != list1[AoB - 1] && MB[k] != list2[AoB - 1] && !MBListed[k]) {
									FB[3] = MB[k];
									MBListed[k] = true;
									last4NotFound = false;
								}
							}
						}
					}
				}
			}
		}
	}
	cout << FB[0] << ' ' << FB[1] << ' ' << FB[2] << ' ' << FB[3];
	delete[] list1;
	delete[] list2;
	delete[] booksListed;
	return 0;
}