Submission #1076546

#TimeUsernameProblemLanguageResultExecution timeMemory
1076546raphaelpPortal (BOI24_portal)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin >> N;
    long long X, Y;
    cin >> X >> Y;
    vector<pair<long long, long long>> Tab;
    for (long long i = 0; i < N - 1; i++)
    {
        long long x, y;
        cin >> x >> y;
        Tab.push_back({x - X, y - Y});
    }
    if (N <= 2)
    {
        cout << -1;
        return 0;
    }
    vector<pair<long long, long long>> Tab2;
    srand(time(0));
    shuffle(Tab.begin(), Tab.end(), rand());
    while (!Tab.empty() && Tab[0].first == 0)
    {
        Tab2.push_back(Tab[0]);
        swap(Tab[0], Tab[Tab.size() - 1]);
        Tab.pop_back();
    }
    while (Tab.size() > 1)
    {
        while (Tab.size() > 1 && Tab[1].first == 0)
        {
            swap(Tab[1], Tab[Tab.size() - 1]);
            Tab2.push_back(Tab[Tab.size() - 1]);
            Tab.pop_back();
        }
        if (Tab.size() == 1)
            break;
        if (abs(Tab[1].first) < abs(Tab[0].first))
            swap(Tab[1], Tab[0]);
        long long x = Tab[1].first / Tab[0].first;
        Tab[1].first -= Tab[0].first * x;
        Tab[1].second -= Tab[0].second * x;
        if (Tab[1].first == 0 && Tab[1].second != 0)
        {
            x = Tab[0].second / Tab[1].second;
            Tab[0].second -= Tab[1].second * x;
        }
        while (Tab[0].second > 1000000000000)
            cout << 1;
    }
    while (!Tab2.empty() && Tab2[0].second == 0)
    {
        swap(Tab2[0], Tab2[Tab2.size() - 1]);
        Tab2.pop_back();
    }
    while (Tab2.size() > 1)
    {
        while (Tab2.size() > 1 && Tab2[1].second == 0)
        {
            swap(Tab2[1], Tab2[Tab2.size() - 1]);
            Tab2.pop_back();
        }
        if (Tab2.size() == 1)
            break;
        if (abs(Tab2[1].second) < abs(Tab2[0].second))
            swap(Tab2[1], Tab2[0]);
        long long x = Tab2[1].second / Tab2[0].second;
        Tab2[1].second -= Tab2[0].second * x;
    }
    if (Tab2.empty())
        cout << -1;
    else
        cout << abs(Tab[0].first * Tab2[0].second);
}

Compilation message (stderr)

In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _UGenerator = int]':
Main.cpp:23:43:   required from here
/usr/include/c++/10/bits/stl_algo.h:3769:2: error: 'std::remove_reference<int>::type' {aka 'int'} is not a class, struct, or union type
 3769 |  __uc_type;
      |  ^~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<int>::type' {aka 'int'} is not a class, struct, or union type
 3797 |    const pair<__uc_type, __uc_type> __pospos =
      |                                     ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<int>::type' {aka 'int'} is not a class, struct, or union type