Submission #119777

# Submission time Handle Problem Language Result Execution time Memory
119777 2019-06-22T09:17:30 Z ahmad_salah Parachute rings (IOI12_rings) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 1e6;
int n, ends;
vector<int> adj[M];
bool v[M], ok;

void dfs(int node, int forb) {
    if (!v[node]) {
        v[node] = 1;

        int cnt = 0;
        for (int x : adj[node])
            if (x != forb)
                cnt++;

        if (cnt > 2) {
            ok = false;
            return;
        }

        if (!cnt)
            ends = 2;
        else if (cnt == 1)
            ends++;

        for (int x : adj[node])
            if (x != forb)
                dfs(x, forb);
    }
}

void Init(int N) { n = N; }

void Link(int a, int b) {
    adj[a].push_back(b);
    adj[b].push_back(a);
}

int CountCritical() {
    int ans = 0;

    for (int i = 0; i < n; i++) {
        memset(v, 0, sizeof v);
        ok = true;
        ends = 0;

        for (int j = 0; j < n; j++)
            if (!v[j] && i != j)
                dfs(j, i);

        ans += (ok && ends == 2);
    }

    return ans;
}

Compilation message

rings.cpp: In function 'void dfs(int, int)':
rings.cpp:25:13: error: reference to 'ends' is ambiguous
             ends = 2;
             ^~~~
rings.cpp:6:8: note: candidates are: int ends
 int n, ends;
        ^~~~
In file included from /usr/include/c++/7/istream:39:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/ostream:602:5: note:                 template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::ends(std::basic_ostream<_CharT, _Traits>&)
     ends(basic_ostream<_CharT, _Traits>& __os)
     ^~~~
rings.cpp:27:13: error: reference to 'ends' is ambiguous
             ends++;
             ^~~~
rings.cpp:6:8: note: candidates are: int ends
 int n, ends;
        ^~~~
In file included from /usr/include/c++/7/istream:39:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/ostream:602:5: note:                 template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::ends(std::basic_ostream<_CharT, _Traits>&)
     ends(basic_ostream<_CharT, _Traits>& __os)
     ^~~~
rings.cpp: In function 'int CountCritical()':
rings.cpp:48:9: error: reference to 'ends' is ambiguous
         ends = 0;
         ^~~~
rings.cpp:6:8: note: candidates are: int ends
 int n, ends;
        ^~~~
In file included from /usr/include/c++/7/istream:39:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/ostream:602:5: note:                 template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::ends(std::basic_ostream<_CharT, _Traits>&)
     ends(basic_ostream<_CharT, _Traits>& __os)
     ^~~~
rings.cpp:54:23: error: reference to 'ends' is ambiguous
         ans += (ok && ends == 2);
                       ^~~~
rings.cpp:6:8: note: candidates are: int ends
 int n, ends;
        ^~~~
In file included from /usr/include/c++/7/istream:39:0,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rings.cpp:1:
/usr/include/c++/7/ostream:602:5: note:                 template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::ends(std::basic_ostream<_CharT, _Traits>&)
     ends(basic_ostream<_CharT, _Traits>& __os)
     ^~~~