Submission #152545

# Submission time Handle Problem Language Result Execution time Memory
152545 2019-09-08T10:53:50 Z stefdasca Flood (IOI07_flood) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007

using namespace std;

vector<pair<pair<int, int>, int> >v;
multiset<pair<pair<int, int>, int > >ms;
int n, m;
vector<pair<int, int> >mch[100005][5];
bool viz[100005];
vector<int> ans;
pr p[100005];
int direction(pair<int, int> a, pair<int, int> b)
{
    if(b.fi == a.fi)
    {
        if(b.se > a.se)
            return 0;
        return 2;
    }
    if(b.fi > a.fi)
        return 1;
    return 3;
}
int go(int nod, int dir)
{
    if (viz[nod])
        return nod;
    viz[nod] = 1;
    for(int i = 0; i < 4; ++i)
    {
        int nxt = ((dir + 1) - i + 4) % 4;
        if(mch[nod][nxt].empty())
            continue;
        auto ed = mch[nod][nxt].front();
        mch[nod][nxt].clear();
        int vecin = ed.y;
        mch[vecin][(nxt + 2) % 4].clear();
        int loop = go(vecin, nxt);
        if(!loop)
        {
            ans.pb(ed.x);
            continue;
        }
        if (loop != nod)
        {
            viz[nod] = 0;
            return loop;
        }
    }
    viz[nod] = 0;
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> p[i].fi >> p[i].se;
        v.pb({p[i], i});
    }
    cin >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        mch[a][direction(p[a], p[b])].pb({i, b});
        mch[b][direction(p[b], p[a])].pb({i, a});
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); ++i)
        go(v[i].se, 0);
    cout << ans.size() << '\n';
    for(int i = 0; i < ans.size(); ++i)
        cout << ans[i] << '\n';
    return 0;
}

Compilation message

flood.cpp:17:1: error: 'pr' does not name a type; did you mean 'pf'?
 pr p[100005];
 ^~
 pf
flood.cpp: In function 'int go(int, int)':
flood.cpp:42:24: error: 'struct std::pair<int, int>' has no member named 'y'
         int vecin = ed.y;
                        ^
flood.cpp:47:23: error: 'struct std::pair<int, int>' has no member named 'x'
             ans.pb(ed.x);
                       ^
flood.cpp: In function 'int main()':
flood.cpp:66:16: error: 'p' was not declared in this scope
         cin >> p[i].fi >> p[i].se;
                ^
flood.cpp:67:23: error: no matching function for call to 'std::vector<std::pair<std::pair<int, int>, int> >::push_back(<brace-enclosed initializer list>)'
         v.pb({p[i], i});
                       ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from flood.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<std::pair<int, int>, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<std::pair<int, int>, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<std::pair<int, int>, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<std::pair<int, int>, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<std::pair<int, int>, int> >::value_type&& {aka std::pair<std::pair<int, int>, int>&&}'
flood.cpp:74:26: error: 'p' was not declared in this scope
         mch[a][direction(p[a], p[b])].pb({i, b});
                          ^
flood.cpp:78:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); ++i)
                    ~~^~~~~~~~~~
flood.cpp:81:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < ans.size(); ++i)
                    ~~^~~~~~~~~~~~