CSES - Datatähti 2016 alku - Results
Submission details
Task:Kirjat
Sender:Chatne
Submission time:2015-09-28 16:54:15 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp:8:16: error: '::main' must return 'int'
 long long main() {
                ^
input/code.cpp: In function 'int main()':
input/code.cpp:61:60: error: no matching function for call to 'find(std::vector<long long int>::iterator, std::vector<long long int>::iterator, long long int&)'
    newList.erase(find(newList.begin(), newList.end(), curid));
                                                            ^
input/code.cpp:61:60: note: candidate is:
In file included from /usr/include/c++/4.9/bits/locale_facets.h:48:0,
                 from /usr/include/c++/4.9/bits/basic_ios.h:37,
                 from /usr/include/c++/4.9/ios:44,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from input/code.cpp:1:
/usr/include/c++/4.9/bits/streambuf_iterator.h:369:5: note: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::...

Code

#include <iostream>
#include <string>
#include <vector>

using namespace std;


long long main() {
	cin.sync_with_stdio(false);

	long long onum,num;
	vector<long long> uList, mList, newList, retList;
	
	cin >> onum;
	num = onum;
	while (num--) {
		long long a;
		cin >> a;
		uList.push_back(a);
	}
	num = onum;
	while (num--) {
		long long a;
		cin >> a;
		mList.push_back(a);
	}

	for (long long i = 1; i <= onum; i++) {
		newList.push_back(i);
	}

	long long curbook = 0;
	long long curday = 0;
	long long failcount = 0;
	while (1) {
		long long bookcount = newList.size();
		long long curid = newList[curbook];
		if (curid == uList[curday] || curid == mList[curday]) {

			if (curbook == (long long)newList.size() - 1) { // FAIL
				curbook = 0;
				curday = 0;
				failcount++;
				newList.clear();
				for (long long i = failcount; i < onum; i++) {
					newList.push_back(i);
				}
				for (long long i = 0; i < failcount+1; i++) {
					newList.push_back(i);
				}
				continue;
			}
			else {
				curbook++;
				continue;
			}

		}
		else {
			retList.push_back(curid);
			newList.erase(find(newList.begin(), newList.end(), curid));
			curbook = 0;

			if (curday == onum - 1) {

				for (long long i = 0; i < onum; i++){
					cout << retList[i] << " ";
				}

				break;
			}
			else {
				curday++;
			}
		}
	}

}