Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-01 00:13:0018
2015-09-30 23:52:150
2015-09-30 23:51:190
2015-09-30 20:26:0218
2015-09-30 20:24:000
2015-09-30 20:22:3718
2015-09-30 20:10:570
2015-09-30 20:09:540
2015-09-30 20:09:540
2015-09-30 20:08:050
2015-09-30 18:52:1818
2015-09-30 18:50:3018
2015-09-30 18:48:530
2015-09-30 18:47:520
2015-09-30 18:13:1018
2015-09-30 18:11:4018
2015-09-30 18:10:2018
2015-09-30 18:05:4518
2015-09-30 17:59:42
2015-09-30 17:54:4518
2015-09-30 16:49:2918
2015-09-30 16:40:1518
2015-09-30 15:38:3018
2015-09-30 14:53:450
2015-09-30 14:53:300
2015-09-30 14:04:080
Task:Kirjat
Sender:viderizer
Submission time:2015-09-30 17:59:42
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:73:36: error: no match for 'operator==' (operand types are 'std::vector<std::tuple<int, int, int> >::iterator {aka __gnu_cxx::__normal_iterator<std::tuple<int, int, int>*, std::vector<std::tuple<int, int, int> > >}' and 'std::vector<std::tuple<int, int, int> >::reverse_iterator {aka std::reverse_iterator<__gnu_cxx::__normal_iterator<std::tuple<int, int, int>*, std::vector<std::tuple<int, int, int> > > >}')
         if (get<2>(*it) == 0 && it == v.rbegin()) {
                                    ^
input/code.cpp:73:36: note: candidates are:
In file included from /usr/include/x86_64-linux-gnu/c++/4.9/bits/c++allocator.h:33:0,
                 from /usr/include/c++/4.9/bits/allocator.h:46,
                 from /usr/include/c++/4.9/string:41,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,

Code

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
#include <set>
#include <algorithm>

using std::string;
using std::cin;
using std::cout;
using std::stoi;
using std::tuple;
using std::vector;
using std::stringstream;
using std::make_tuple;
using std::tuple_element;
using std::getline;
using std::get;
using std::find;

void debug(vector<int> v) {
    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
        cout << *it << " ";
    }

    cout << "\n";
}

int main(int argc, char** argv) {
    // input
    int n;
    string n_s;
    string uolevi;
    string maija;

    getline(cin, n_s);
    n = stoi(n_s);
    getline(cin, uolevi);
    getline(cin, maija);

    // parsing input
    vector<tuple<int, int, int>> v;
    stringstream ss(uolevi);
    stringstream ss2(maija);
    string sub;
    string sub2;

    while (getline(ss, sub, ' ') && getline(ss2, sub2, ' ')) {
        v.push_back(make_tuple(stoi(sub), stoi(sub2), 0));
    }

    vector<int> unread;
    for (vector<tuple<int, int, int>>::reverse_iterator it = v.rbegin(); it != v.rend(); ++it) {
        if (find(unread.begin(), unread.end(), get<0>(*it)) == unread.end()) {
            unread.push_back(get<0>(*it));
        }
        if (find(unread.begin(), unread.end(), get<1>(*it)) == unread.end()) {
            unread.push_back(get<1>(*it));
        }
    }

    stringstream result_ss;

    for (vector<tuple<int, int, int>>::iterator it = v.begin(); it != v.end(); ++it) {
        for (vector<int>::iterator it2 = unread.begin(); it2 != unread.end(); ++it2) {
            if (*it2 != get<0>(*it) && *it2 != get<1>(*it)) {
                *it = make_tuple(get<0>(*it), get<1>(*it), *it2);
                unread.erase(it2);
                break;
            }
        }
        if (get<2>(*it) == 0 && it == v.rbegin()) {
            return 1;
        }
        //cout << "(" << get<0>(*it) << ", " << get<1>(*it) << ", " << get<2>(*it) << "), ";
        result_ss << get<2>(*it) << " ";
    }



    string result_s(result_ss.str());
    result_s.pop_back();

    cout << result_s << "\n";
    return 0;
}