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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (curbook == newList.size() - 1) { // FAIL
                ^
input/code.cpp:60:60: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
    newList.erase(find(newList.begin(), newList.end(), curid));
                                                            ^
input/code.cpp:60: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>::__valu...

Code

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

using namespace std;


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

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

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

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

			if (curbook == newList.size() - 1) { // FAIL
				curbook = 0;
				curday = 0;
				newList.clear();
				for (int i = failcount; i < onum; i++) {
					newList.push_back(i);
				}
				for (int 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 (int i = 0; i < onum; i++){
					cout << retList[i] << " ";
				}

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

}