Hi,
After speeding up my BigNum, I keep get WA in 1.9 seconds.
I tried many many cases and it gives the correct result.
Does anyone have more tricky cases

? Thanks.
My setup is shown below, if you feel like reading it and finding a
counter example. I keep multiplying the spacing by k and add 1, while going
backwards in candidates. Thanks!
Code: Select all
int main()
{
int t,zz=0; cin2 >> t;
int n,m;
inf=0; REP(i,55) inf=(inf+1)*50;
while(t--)
{
cin2 >> n >> m;
memset( cap, 0, sizeof( cap ) );
zz++;
int s=n+m, t=n+m+1;
REP(job,m) // spots
{
int r; cin2 >> r;
cap[n+job][t]=r;
cost[n+job][t]=0LL;
}
vector<vector<int> > jobs(n);
REP(cand,n)
{
int k; cin2 >> k;
while(k--) {int u; cin2>>u; u--; jobs[cand].push_back(u);}
}
vector<BigNum> space(n);
space[n-1]=1;
FORD(i,n-2,0)
{
space[i]=space[i+1]*((int)jobs[i+1].size())+1;
}
BigNum prev=0LL,best=0LL;
REP(cand,n) // candidates
{
cap[s][cand]=1;
cost[s][cand]=0LL;
REP(i,jobs[cand].size())
{
int job=jobs[cand][i];
cap[cand][n+job]=1;
cost[cand][n+job]=prev+space[cand];
prev=cost[cand][n+job]+0LL;
}
}
cout << "Case #" << zz << ":" << endl;
int flow = max_flow_min_cost(t+1, s, t);
cout << flow << " applicant(s) can be hired." << endl;
REP(i,n)
{
REP(j,m)
{
if(fnet[i][n+j])
{
cout << i+1 << " " << j+1 << endl;
break;
}
}
}
}
return 0;
}