Submission #219679

# Submission time Handle Problem Language Result Execution time Memory
219679 2020-04-05T23:20:26 Z thebes Lokahian Relics (FXCUP4_lokahia) C++17
Compilation error
0 ms 0 KB
#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MN = 205;
mt19937 mt(time(0));
int rng(int l,int r){return (mt()%(r-l+1))+l;}
set<int> elem[MN], bel[MN], adj[MN]; set<pair<int,int>> use;
int ord[MN], a, b, count;
 
int FindBase(int N){
    if(N==1) return 0;
    for(int i=0;i<min(99,N*(N-1)/2);i++){
        int x = rng(0,N-1), y = rng(0,N-1);
        while(x==y||use.count({x,y})){
            x = rng(0,N-1), y =rng(0,N-1);
        }
        use.insert({x,y});
        int rt = CollectRelics(x, y); count++;
        if(rt!=-1){
            elem[rt].insert(x);
            elem[rt].insert(y);
            bel[x].insert(rt);
            bel[y].insert(rt);
        }
        else{
            adj[x].insert(y);
            adj[y].insert(x);
        }
    }
    for(int i=0;i<N;i++) ord[i]=i;
    sort(ord,ord+N,[](int i,int j){return elem[i].size()>elem[j].size();});
    a=ord[0], b=ord[1];
    int Q = min(99,N*(N-1)/2);
    int rt = CollectRelics(a,b); count++;
    if(rt==-1&&elem[b].size()<Q/4-7) rt=a;
    if(rt!=-1){
        int cnt = 1;
        for(int i=0;i<N;i++){
            if(i!=rt&&CollectRelics(rt,i)!=-1) cnt++;
        }
        if(cnt>(N/2)) return rt;
        else return -1;
    }
    else{
        bel[a].insert(a); bel[b].insert(b);
        adj[a].insert(b); adj[b].insert(a);
        int ca = bel[a].size(), cb = bel[b].size();
        for(int i=0;i<N;i++){
            int chka=1, chkb=0;
            for(auto v : adj[i]){
                if(bel[a].count(v)) chka=0;
                if(bel[b].count(v)) chkb=0;
            }
            if(bel[a].count(i)) chka=0;
            if(bel[b].count(i)) chkb=0;
            if(chka&&CollectRelics(a,i)!=-1) ca++,count++;
          	if(count==300) break;
            if(chkb&&CollectRelics(b,i)!=-1) cb++,count++;
          	if(count==300) break;
        }
        if(ca>(N/2)) return a;
        else if(cb>(N/2)) return b;
        else return -1;
    }
}

Compilation message

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:19:39: error: reference to 'count' is ambiguous
         int rt = CollectRelics(x, y); count++;
                                       ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~
lokahia.cpp:35:34: error: reference to 'count' is ambiguous
     int rt = CollectRelics(a,b); count++;
                                  ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~
lokahia.cpp:36:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(rt==-1&&elem[b].size()<Q/4-7) rt=a;
                ~~~~~~~~~~~~~~^~~~~~
lokahia.cpp:57:51: error: reference to 'count' is ambiguous
             if(chka&&CollectRelics(a,i)!=-1) ca++,count++;
                                                   ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~
lokahia.cpp:58:15: error: reference to 'count' is ambiguous
            if(count==300) break;
               ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~
lokahia.cpp:59:51: error: reference to 'count' is ambiguous
             if(chkb&&CollectRelics(b,i)!=-1) cb++,count++;
                                                   ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~
lokahia.cpp:60:15: error: reference to 'count' is ambiguous
            if(count==300) break;
               ^~~~~
lokahia.cpp:9:20: note: candidates are: int count
 int ord[MN], a, b, count;
                    ^~~~~
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from lokahia.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4076:5: note:                 template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)
     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     ^~~~~