QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#281630#3249. 分组作业wtcc#WA 12ms7768kbC++141.8kb2023-12-10 14:33:302023-12-10 14:33:30

Judging History

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

  • [2023-12-10 14:33:30]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:7768kb
  • [2023-12-10 14:33:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=100009,INF=1e18;
inline int read(){int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1; ch=getchar(); } while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
void write(int x){if(x<0) putchar('-'),x=-x;if(x>9) write(x/10); putchar(x%10+'0');return;}
ll n,a[N];
ll s,t,nE=1,m;
ll to[N],nxt[N],hd[N],cap[N];
void adde(ll u,ll v,ll c){
    nE++;
    to[nE]=v;
    nxt[nE]=hd[u];
    hd[u]=nE;
    cap[nE]=c;
}
void add(ll u,ll v,ll c){
	adde(u,v,c);
	adde(v,u,0);
}
ll lv[N];
bool vst[N];
bool bfs(){
    fill(lv,lv+1+nE,0);
    queue<ll> q;
    lv[s]=1;
    q.push(s);
    while(!q.empty()){
        ll u=q.front(); q.pop();
        for(ll i=hd[u];i;i=nxt[i]){
            ll c=cap[i];
            if(!c) continue;
            ll v=to[i];
            if(lv[v]) continue;
            q.push(v);
            lv[v]=lv[u]+1;
        }
    }
    return lv[t];
}
ll maxflow(ll s,ll f){
    ll sum=0;
    if(s==t) return f;
    for(ll i=hd[s];i;i=nxt[i]){
        ll v=to[i];
        ll c=cap[i];
        if(!c) continue;
        if(lv[v]!=lv[s]+1) continue;
        ll delta=maxflow(v,min(f,c));
        sum+=delta;
        f-=delta;
        cap[i]-=delta;
        cap[i^1]+=delta;
    }
    return sum;
}
void Dinic(){
    ll ans=0;
    while(bfs()){
        ans+=maxflow(s,INF);
    }
    cout<<ans<<endl;
}
int main(){
    cin>>n>>m;
    s=0; t=3*n+1;
    for(ll i=1,c,d,e;i<=2*n;i++){
    	cin>>c>>d>>e;
    	add(s,i,d);
    	add(i,2*n+((i+1)/2),c);
    	add(2*n+(i+1)/2,t,c);
    	add(i,(i%2?i+1:i-1),e);
    	add(2*n+(i+1)/2,i,INF);
    }
    for(ll i=1;i<=m;i++){
    	int x,y,a,b; cin>>x>>y>>a>>b;
    	add(2*n+(y+1)/2,x,b);
    	add(y,2*n+(x+1)/2,a);
    }
    Dinic();
	return 0;
	
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 12ms
memory: 7768kb

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:

0

result:

wrong answer 1st lines differ - expected: '22929674417', found: '0'