QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#38782 | #1454. Um nik's Algorithm | wyhao | Compile Error | / | / | C++ | 1.4kb | 2022-07-07 13:39:01 | 2022-07-07 13:39:13 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-07-07 13:39:13]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-07-07 13:39:01]
- 提交
answer
#include<cstdio>
#include<cstring>
using namespace std;
const int N=2000005,M=N<<3;
int n1,n2,m,cnt,S,T;
int to[M],nxt[M],f[M],h[N<<1];
void add(int i,int x,int y,int z){
to[i]=y;f[i]=z;nxt[i]=h[x];h[x]=i;
}
int cur[N<<1],dep[N<<1];
int que[N<<1],op,cl;
bool bfs(){
memset(dep,0,sizeof dep);
memcpy(cur,h,sizeof cur);
op=0;cl=1;que[1]=S;dep[S]=1;
while(op<cl){
int x=que[++op];
for(int i=h[x],y;i;i=nxt[i]){
y=to[i];
if(!f[i]) continue;
if(!dep[y]){
dep[y]=dep[x]+1;
que[++cl]=y;
}
if(y==T) return true;
}
}
return false;
}
int min1(int x,int y){
return x<y?x:y;
}
int dfs(int x,int lim){
if(x==T) return lim;
int flow=lim,k;
for(int &i=cur[x],y;i;i=nxt[i]){
y=to[i];
if(dep[y]==dep[x]+1 and f[i]){
k=dfs(y,min1(f[i],flow));
flow-=k;f[i]-=k;f[i^1]+=k;
if(!flow) break;
}
}
if(flow) dep[x]=0;
return lim-flow;
}
int main(){
scanf("%d%d%d",&n1,&n2,&m);
S=n1+n2+1;T=S+1;cnt=1;
for(int i=1,x,y;i<=m;i++){
scanf("%d%d",&x,&y);
add(++cnt,x,y+n1,1);
add(++cnt,y+n1,x,0);
}
for(int i=1;i<=n1;i++){
add(++cnt,S,i,1);
add(++cnt,i,S,0);
}
for(int i=1;i<=n2;i++){
add(++cnt,i+n1,T,1);
add(++cnt,T,i+n1,0);
}
int ans=0;
if(n<=10000){
while(bfs()) ans+=dfs(S,min1(n1,n2));
}else{
if(bfs()) ans+=dfs(S,min1(n1,n2));
}
printf("%d\n",ans);
for(int i=1;i<=m;i++){
if(!f[i<<1]) printf("%d\n",i);
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:64:12: error: ‘n’ was not declared in this scope 64 | if(n<=10000){ | ^ answer.code:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d%d%d",&n1,&n2,&m); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ answer.code:51:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | scanf("%d%d",&x,&y); | ~~~~~^~~~~~~~~~~~~~