QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#479447 | #143. 最大流(随机数据) | liuhangxin# | Compile Error | / | / | C++14 | 1.5kb | 2024-07-15 17:34:28 | 2024-07-15 17:34:28 |
Judging History
This is the latest submission verdict.
- [2024-07-15 17:34:28]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-15 17:34:28]
- Submitted
answer
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N=110,M=1e4+10;
const ll inf=1e18;
int n,m,s,t;
int h[N],e[M],ne[M],w[M],idx;
void add(int a,int b,int W)
{
e[idx]=b;
w[idx]=W;
ne[idx]=h[a];
h[a]=idx++;
e[idx]=a;
w[idx]=0;
ne[idx]=h[b];
h[b]=idx++;
}
ll maxflow;
int d[N],cur[N];
bool bfs()
{
memset(d,-1,sizeof d);
memcpy(cur,h,sizeof cur);
queue<int>q;
q.push(s);d[s]=0;
while(!q.empty())
{
int u=q.front();q.pop();
for(int i=h[u];i!=-1;i=ne[i])
{
int v=e[i];
if(d[v]==-1&&w[i]){
d[v]=d[u]+1;
q.push(v);
}
}
}
return d[t]!=-1;
}
ll dfs(int u,ll flow)
{
if(u==t||!flow)return flow;
ll remin=flow;
for(int i=cur[u];i!=-1;i=ne[i])
{
int v=e[i];
cur[u]=i;
if(d[v]==d[u]+1&&w[i])
{
ll x=dfs(v,min(w[i],remin));
remin-=x;
w[i]-=x;w[i^1]+=x;
}
}
return flow-remin;
}
void Dinic()
{
while(bfs())
maxflow+=dfs(s,inf);
}
int main()
{
// freopen("1.in","r",stdin);
memset(h,-1,sizeof h);
scanf("%d%d%d%d",&n,&m,&s,&t);
for(int i=1;i<=m;i++)
{
int u,v,c;
scanf("%d%d%d",&u,&v,&c);
add(u,v,c);
}
Dinic();
printf("%lld\n",maxflow);
return 0;
}
詳細信息
answer.code: In function ‘long long int dfs(int, long long int)’: answer.code:54:27: error: no matching function for call to ‘min(int&, long long int&)’ 54 | ll x=dfs(v,min(w[i],remin)); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:54:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 54 | ll x=dfs(v,min(w[i],remin)); | ~~~^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:54:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’) 54 | ll x=dfs(v,min(w[i],remin)); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’ 5775 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5775:5: note: template argument deduction/substitution failed: answer.code:54:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 54 | ll x=dfs(v,min(w[i],remin)); | ~~~^~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’ 5785 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: template argument deduction/substitution failed: answer.code:54:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 54 | ll x=dfs(v,min(w[i],remin)); | ~~~^~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:70:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 70 | scanf("%d%d%d%d",&n,&m,&s,&t); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ answer.code:74:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 74 | scanf("%d%d%d",&u,&v,&c); | ~~~~~^~~~~~~~~~~~~~~~~~~