Submission #15979

# Submission time Handle Problem Language Result Execution time Memory
15979 2015-08-04T09:46:49 Z gs14004 Cop and Robber (BOI14_coprobber) C++14
Compilation error
0 ms 0 KB
#include "coprobber.h"
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
int indeg[500][500][2];
 
queue<int> qx, qy, qd;
bool vis[500][500][2];
int nxt[500][500];
int pos;
 
int start(int N, bool A[MAX_N][MAX_N])
{
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if (i == j) continue;
            indeg[i][j][1] = count(A[j], A[j] + N, true);
            indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
        }
    } 
    for (int i = 0; i < N; i++){
        for (int k = 0; k < 2; k++){
            qx.push(i);
            qy.push(i);
            qd.push(k);
            vis[i][i][k] = 1;
        }
    }
    while (!qx.empty()){
        int xf = qx.front();
        int yf = qy.front();
        int df = qd.front();
        qx.pop(), qy.pop(), qd.pop();
        if (df == 1){
            for (int i = 0; i < N; i++){
                if (A[xf][i] && !vis[i][yf][0]){
                    indeg[i][yf][0]--;
                    if (indeg[i][yf][0] == 0){
                        qx.push(i);
                        qy.push(yf);
                        qd.push(0);
                        nxt[i][yf] = xf;
                        vis[i][yf][0] = 1;
                    }
                }
            }
        }
        else{
            for (int i = 0; i < N; i++){
                if (A[yf][i] &&!vis[xf][i][1]){
                    indeg[xf][i][1]--;
                    if (indeg[xf][i][1] == 0){
                        qx.push(xf);
                        qy.push(i);
                        qd.push(1);
                        vis[xf][i][1] = 1;
                    }
                }
            }
        }
    }
    for (int i = 0; i < N; i++){
        int fnd = 0;
        for (int j = 0; j < N; j++){
            if (!vis[i][j][0]){
                fnd = 1;
                break;
            }
        }
        if (!fnd) return pos = i;
    }
    return -1;
}
 
int nextMove(int R)
{
    return pos = nxt[pos][R];
}

Compilation message

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:20:64: error: no matching function for call to 'min(std::iterator_traits<bool*>::difference_type, int)'
             indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
                                                                ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from coprobber.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
coprobber.cpp:20:64: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
             indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
                                                                ^
In file included from /usr/include/c++/7/algorithm:61:0,
                 from coprobber.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
coprobber.cpp:20:64: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
             indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
                                                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from coprobber.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
coprobber.cpp:20:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
             indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
                                                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from coprobber.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
coprobber.cpp:20:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
             indeg[i][j][0] = min(count(A[i], A[i] + N, true), 1);
                                                                ^