QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93134#143. 最大流(随机数据)RevolutionBP#Compile Error//C++142.4kb2023-03-31 11:41:292023-03-31 11:41:30

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-31 11:41:30]
  • 评测
  • [2023-03-31 11:41:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair <int, int>;

template <typename T>
inline void read(T &x) {
    x = 0; char c = getchar();
    int f = 0;
    for (; !isdigit(c); c = getchar()) f |= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    if (f) x = -x;
}

template <typename T, typename ...Args>
inline void read(T &x, Args &...args) {
    read(x), read(args...);
}
template <typename T>
inline void write(T x, char ch) {
    if (x < 0) x = -x, putchar('-');
    static short st[70], tp;
    do st[++tp] = x % 10, x /= 10; while (x);
    while (tp) putchar(st[tp--] | 48);
    putchar(ch);
}

template <typename T, typename ...Args>
inline void write(T x, char ch, Args ...args) {
    write(x, ch), write(args...);
}

#define Fr(i,l,r) for (int i = (l); i <= (r); ++i)
#define Rf(i,r,l) for (int i = (r); i >= (l); --i)

const int N = 1e6 + 5;

int n, m, S, T;

struct edge {
    int to, nxt, val;
}e[N << 1];

int head[N], edge_cnt = 1;

inline void add(int u, int v, int w) {
    e[++edge_cnt] = {v, head[u], w};
    head[u] = edge_cnt;
}

inline void link(int u, int v, int w) {
    add(u, v, w), add(v, u, 0);
}

int dep[N], cur[N];

inline bool bfs() {
    memset(dep, 0, sizeof(dep));
    memset(cur, 0, sizeof(cur));
    dep[S] = 1;
    queue <int> q;
    q.push(S);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        cur[u] = head[u];
        for (int i = head[u]; i; i = e[i].nxt) {
            int v = e[i].to, w = e[i].val;
            if (!dep[v] && w) {
                dep[v] = dep[u] + 1;
                q.push(v);
            }
        }
    }
    return dep[T];
}

inline ll dfs(int u, ll flow_in) {
    if (u == T) return flow_in;
    ll flow_out = 0;
    for (int i = cur[u]; i && flow_in; i = e[i].nxt) {
        cur[u] = i;
        int v = e[i].to;
        if (dep[v] == dep[u] + 1 && e[i].val) {
            int out = dfs(v, min(flow_in, e[i].val));
            flow_in -= out, flow_out += out;
            e[i].val -= out, e[i ^ 1].val += out;
        }
    }
    if (!flow_out) dep[u] = 0;
    return flow_out;
}

inline ll Dinic() { ll x = 0; while (bfs()) x += dfs(S, 2000000000); return x;}

signed main() {
    read(n, m, S, T);
    Fr (i, 1, m) {
        int u, v, w;
        read(u, v, w);
        link(u, v, w);
    }
    write(Dinic(), '\n');
    return 0;
}

详细

answer.code: In function ‘ll dfs(int, ll)’:
answer.code:85:33: error: no matching function for call to ‘min(ll&, int&)’
   85 |             int out = dfs(v, min(flow_in, e[i].val));
      |                              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
answer.code:85:33: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   85 |             int out = dfs(v, min(flow_in, e[i].val));
      |                              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
answer.code:85:33: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   85 |             int out = dfs(v, min(flow_in, e[i].val));
      |                              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)’
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
answer.code:85:33: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   85 |             int out = dfs(v, min(flow_in, e[i].val));
      |                              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)’
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
answer.code:85:33: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   85 |             int out = dfs(v, min(flow_in, e[i].val));
      |                              ~~~^~~~~~~~~~~~~~~~~~~