CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:viderizer
Submission time:2015-09-30 23:53:43 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.14 s1details
#20.14 s1details
#30.12 s1details
#40.14 s1details
#50.14 s1details
#60.14 s2details
#70.15 s2details
#80.14 s2details
#90.14 s2details
#100.13 s2details
#110.14 s3details
#120.15 s3details
#130.15 s3details
#140.15 s3details
#150.15 s3details

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:32:9: warning: variable 'n' set but not used [-Wunused-but-set-variable]
     int n;
         ^

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;

    vector<int> unread;

    while (getline(ss, sub, ' ') && getline(ss2, sub2, ' ')) {
        int i = stoi(sub);
        int j = stoi(sub2);
        v.push_back(make_tuple(i, j, 0));
        if (find(unread.begin(), unread.end(), i) == unread.end()) {
            unread.insert(unread.begin(), i);
        }
        if (find(unread.begin(), unread.end(), j) == unread.end()) {
            unread.insert(unread.begin(), j);
         }
    }

    //for (vector<tuple<int, int, int>>::reverse_iterator it = v.rbegin(); it != v.rend(); ++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 + 2 == v.end())) {
        //    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;
}

Test details

Test 1

Group: 1

Verdict:

input
BBBAABBBAAAABBAAAABAABAABBBBBB...

correct output
2554

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 2

Group: 1

Verdict:

input
GDFVYWQCZAFGICSXOSWBZMGPDBSSVL...

correct output
299

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 3

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAZAAAA...

correct output
4314

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 4

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4231

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 5

Group: 1

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5050

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 6

Group: 2

Verdict:

input
BBABABBBABBAABBABBABAABAAABABA...

correct output
6253029

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 7

Group: 2

Verdict:

input
RBKJMLDVQMKHYKCNDIVVKOMFUXTFMG...

correct output
485173

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 8

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12427725

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 9

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12467549

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 10

Group: 2

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
12502500

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 11

Group: 3

Verdict:

input
BAAAAABABBABAABAABABABBBABBAAB...

correct output
2500051369

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 12

Group: 3

Verdict:

input
ABBURXDRVXAYBPXXOQZNYHLWGUEEWR...

correct output
192407124

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 13

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998050400

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 14

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998850144

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi

Test 15

Group: 3

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5000050000

user output
(empty)

Error:
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi