QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#24776 | #3249. 分组作业 | suimu | WA | 36ms | 11924kb | C++20 | 2.3kb | 2022-04-02 23:51:34 | 2022-04-30 06:35:51 |
Judging History
answer
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define dmin(a,b) ((a)<(b)?(a):(b))
namespace io
{
int F()
{
int n=0,F=0;
char ch;
while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
ch=='-'?F=1:n=ch-'0';
while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
return F?-n:n;
}
long long G()
{
long long n=0,F=0;
char ch;
while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
ch=='-'?F=1:n=ch-'0';
while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
return F?-n:n;
}
}
int R(int l,int r)
{
return rand()%(r-l+1)+l;
}
struct edge
{
int to;
long long cap;
int next;
}e[4444444];
int pe=444444;
void insert(int a,int to,long long cap)
{
e[pe]=(edge){to,cap,e[a].next};
e[a].next=pe++;
}
void addedge(int a,int to,long long cap)
{
insert(a,to,cap);
insert(to,a,0);
}
int pno;
int indiv[111111],team[111111],ptn[111111];
int S,T;
int d[111111],q[111111],hq,tq,vis[111111],pv;
int cur[111111];
bool bfs()
{
for(q[hq=1]=T,tq=2,vis[T]=++pv;hq!=tq;++hq)
for(int p=e[q[hq]].next;p;p=e[p].next)
if(vis[e[p].to]!=pv&&e[p^1].cap)
vis[e[p].to]=pv,d[e[p].to]=d[q[hq]]+1,q[tq++]=e[p].to;
return vis[S]==pv;
}
long long dfs(int o,long long min)
{
if(o==T||min==0)return min;
long long f=0,tmp;
for(int &p=cur[o];p;p=e[p].next)
if(e[p].cap&&d[e[p].to]==d[o]-1&&(tmp=dfs(e[p].to,dmin(min,e[p].cap))))
{
e[p].cap-=tmp;
e[p^1].cap+=tmp;
f+=tmp;
min-=tmp;
if(min==0)return f;
}
return f;
}
long long dinic()
{
long long flow=0;
while(bfs())
{
for(int i=1;i<=T;++i)
cur[i]=e[i].next;
flow+=dfs(S,0x3f3f3f3f3f3f3f3fll);
}
return flow;
}
int main()
{
int n=io::F(),m=io::F();
for(int i=1;i<=2*n;++i)
indiv[i]=++pno;
for(int i=1;i<=2*n;++i)
ptn[i]=(i-1^1)+1;
for(int i=1;i<=n;++i)
team[i]=++pno;
S=++pno;
T=++pno;
for(int i=1;i<=2*n;++i)
{
int c=io::F(),d=io::F(),e=io::F();
addedge(S,indiv[i],d);
addedge(indiv[i],team[i+1>>1],c);
// addedge(team[i+1>>1],indiv[i],0x3f3f3f3f3f3f3f3fll);
addedge(team[i+1>>1],T,c);
addedge(indiv[i],indiv[ptn[i]],e);
}
for(int i=1;i<=m;++i)
{
int A=io::F(),B=io::F(),a=io::F(),b=io::F();
addedge(indiv[B],team[A+1>>1],a);
addedge(team[B+1>>1],indiv[A],b);
}
printf("%lld\n",dinic());
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 36ms
memory: 11924kb
input:
5000 10000 23060775 12 2 255978380 28 517 5 6624 26 151149 45131806 23849036 489 484971 24970 162846 1993316 188305 56311199 2003 211 1 50534913 517527 364913 882765 298 71 26 122914059 13 65459 18150033 20 607 8 380059068 3873712 228 9813 5449 6370 3309369 37410691 8 181 1 62340851 1705 4 107 8 209...
output:
22221781891
result:
wrong answer 1st lines differ - expected: '22929674417', found: '22221781891'