QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#479084#143. 最大流(随机数据)yyandy#Compile Error//C++141.2kb2024-07-15 14:50:462024-07-15 14:50:46

Judging History

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

  • [2024-07-15 14:50:46]
  • 评测
  • [2024-07-15 14:50:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=3e4+5;
const ll inf=1e18;
int tot=1,S,T,hd[N],nwhd[N],dep[N],nt[M],pt[M],vl[M],nwfl[M];
int n,m;
inline void addedge(int x,int y,int w){
	++tot;nt[tot]=hd[x];pt[tot]=y;vl[tot]=w;hd[x]=tot;
}
inline bool bfs(){
	queue<int> q;q.push(S);
	memcpy(nwhd,hd,sizeof(hd));
	for(int i=0;i<=n;++i)dep[i]=-1;
	dep[S]=0;
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=hd[x];i;i=nt[i])
			if(dep[pt[i]]<0&&vl[i]>nwfl[i]){
				dep[pt[i]]=dep[x]+1;
				q.push(pt[i]);
			}
	}
	return dep[T]>=0;
}
inline ll dfs(int x,ll fl){
	if(x==T)return fl;
	if(!fl)return 0;
	ll tfl=0;
	for(int i=nwhd[x];i;i=nt[i]){
		nwhd[x]=i;
		if(dep[pt[i]]==dep[x]+1){
			int pmfl=min(fl,(ll)vl[i]-nwfl[i]);
			if(pmfl){
				pmfl=dfs(pt[i],pmfl);
				fl-=pmfl;tfl+=pmfl;
				nwfl[i]+=pmfl;
				nwfl[i^1]-=pmfl;
			}
		}
		if(!fl)break;
	}
	if(!tfl)dep[x]=-1;
	return tfl;
}
int main(){
	ios::ysnc_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>S>>T;
	for(int i=1,x,y,w;i<=m;++i)
		cin>>x>>y>>w,addedge(x,y,w),addedge(y,x,0);
	ll ans=0;
	while(bfs())
		ans+=dfs(S,inf);
	cout<<ans<<'\n';
}

详细

answer.code: In function ‘int main()’:
answer.code:47:14: error: ‘ysnc_with_stdio’ is not a member of ‘std::ios’ {aka ‘std::basic_ios<char>’}
   47 |         ios::ysnc_with_stdio(0);
      |              ^~~~~~~~~~~~~~~