CSES - Datatähti 2018 loppu - Results
Submission details
Task:Tanssiaiset
Sender:SeveriK
Submission time:2018-01-18 14:36:51 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:51:28: error: 'o' was not declared in this scope
             cout << inputs[o * 2] << " " << inputs[o * 2 + 1] << "\n";
                            ^

Code

#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    unsigned long long n;

    cin >> n;


    vector<unsigned long long> inputs;

    for(unsigned long long i = 0; i < n/2 + 1; i++)
    {
        unsigned long long a = 0;
        cin >> a;
        inputs.push_back(a);
        cin >> a;
        inputs.push_back(a);
    }
    bool f1 = false, f2 = false;
    for(unsigned long long i = 0; i < n/2 + 1; i++){
        for(unsigned long long o = 0; o < n/2 + 1; o++){
            if(o != i){
                if(inputs[o * 2] == inputs[i * 2])
                {
                    f1 = true;
                }
                else if(inputs[o * 2 + 1] == inputs[i * 2])
                {
                    f1 = true;
                }
                else if(inputs[o * 2] == inputs[i * 2 + 1])
                {
                    f2 = true;
                }
                else if(inputs[o * 2 + 1] == inputs[i * 2 + 1])
                {
                    f2 = true;
                }
            }
        }
        if(f1 == true && f2 == true)
        {
            cout << inputs[o * 2] << " " << inputs[o * 2 + 1] << "\n";
            return 0;
        }
    }

    return 0;
}