Submission #66840

#TimeUsernameProblemLanguageResultExecution timeMemory
66840KubalionzzaleGame (IOI14_game)C++14
Compilation error
0 ms0 KiB
#include "game.h"

#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

std::vector< std::vector<int> > g(1510);

int cnt[1510] = { 0 }, cnting = 0;
int curi, curj;
int n;
bool visited[1510] = { 0 };

void dfs(int index)
{
    ++cnting;
    for (int i = 0; i < g[index].size(); ++i)
    {
        int next = g[index][i];

        if ((curi == index && curj == next) || (curi == next && curj == index))
        {
            continue;
        }

        if (!visited[next])
            dfs(next);
    }


}

void dfss(int index)
{
    for (int i = 0; i < n; ++i)
    {
        visited[i] = 0;
    }
    dfs(0);
}

void initialize(int N) {
    n = N;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i == j)
                continue;
            g[i].push_back(j);
            g[j].push_back(i);
        }
    }
}

int hasEdge(int u, int v) {
    curi = u;
    curj = v;
    dfss(0);

    if (cnting == n)
    {
        return 0;
    }
    else
    {
        for (int i = 0; i < g[u].size(); ++i)
        {
            if (g[u][i] == v)
            {
                g[u].erase(i);
                break;
            }
        }

        for (int i = 0; i < g[v].size(); ++i)
        {
            if (g[v][i] == u)
            {
                g[v].erase(i);
                break;
            }
        }
    }
}

Compilation message (stderr)

game.cpp: In function 'void dfs(int)':
game.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < g[index].size(); ++i)
                     ~~^~~~~~~~~~~~~~~~~
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:68:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < g[u].size(); ++i)
                         ~~^~~~~~~~~~~~~
game.cpp:72:29: error: no matching function for call to 'std::vector<int>::erase(int&)'
                 g[u].erase(i);
                             ^
In file included from /usr/include/c++/7/vector:64:0,
                 from game.cpp:6:
/usr/include/c++/7/bits/stl_vector.h:1179:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __position)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1179:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator {aka __gnu_cxx::__normal_iterator<const int*, std::vector<int> >}'
/usr/include/c++/7/bits/stl_vector.h:1206:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __first, const_iterator __last)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1206:7: note:   candidate expects 2 arguments, 1 provided
game.cpp:77:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < g[v].size(); ++i)
                         ~~^~~~~~~~~~~~~
game.cpp:81:29: error: no matching function for call to 'std::vector<int>::erase(int&)'
                 g[v].erase(i);
                             ^
In file included from /usr/include/c++/7/vector:64:0,
                 from game.cpp:6:
/usr/include/c++/7/bits/stl_vector.h:1179:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __position)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1179:7: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator {aka __gnu_cxx::__normal_iterator<const int*, std::vector<int> >}'
/usr/include/c++/7/bits/stl_vector.h:1206:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       erase(const_iterator __first, const_iterator __last)
       ^~~~~
/usr/include/c++/7/bits/stl_vector.h:1206:7: note:   candidate expects 2 arguments, 1 provided
game.cpp:86:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^