CSES - Datatähti 2016 alku - Results
Submission details
Task:Kirjat
Sender:hugo-hur
Submission time:2015-10-05 20:44:47 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:46:9: error: expected type-specifier before ')' token
   catch(){}
         ^

Code

#include <iostream>
#include <string>
#include <vector>
//#include <forward_list>
#include <stdio.h>
//using namespace std;

inline void readToArray(unsigned int n, unsigned int* ptr){
	for (unsigned int i = 0; i < n; i++){
		std::cin >> ptr[i];
	}
}
int main() {
	std::cin.sync_with_stdio(false);//Faster execution
	unsigned int n = 0;
	std::cin >> n;
	unsigned int* uolevinJarjestys = new unsigned int[n];
	unsigned int* maijanJarjestys = new unsigned int[n];
	readToArray(n, uolevinJarjestys);
	readToArray(n, maijanJarjestys);

	/*unsigned long* num = new unsigned long[n];
	for (unsigned long i = 0; i<n; i++){
		num[i] = 0;
	}*/
	std::vector < unsigned int >toTry;
	for (unsigned int i = 1; i <= n; i++){
		toTry.push_back(i);
	}
	//Etsi lukujono, joka on välillä 0<num[x]<n && num[x] != uolevinJärjestys[x] && num[x] != maijanJärjestys[x]
	for (unsigned long i = 0; i < n; i++){
		unsigned long z = 0;
		
		//if(toTry.size() == 0){break;}
		unsigned int x = toTry.at(z);
		
		while (x == uolevinJarjestys[i] || x == maijanJarjestys[i]){
			z++;
			//toTry.pop_front();
			x = toTry.at(z);
		}
		//Remove used entry from the list
		try{
			toTry.erase(toTry.begin() + z);
		}
		catch(){}
		
		//num[i] = x;
		std::cout << x << ' ';
	}
	std::cout << std::endl;
	
	return 0;
}