QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110310 | #5036. 卑鄙的下毒人 | 275307894a | 10 | 451ms | 48448kb | C++14 | 1.6kb | 2023-06-01 15:10:22 | 2023-06-01 15:10:24 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define PB push_back
#define fi first
#define se second
using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;
using namespace std;const int N=5e5+5,M=1e3+5,K=100+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m,k,x,y,z,S,T;
struct yyy{int to,w,g,z;};struct ljb{int head=1,h[N];yyy f[N*4];void add(int x,int y,int w,int g){f[++head]=(yyy){y,w,g,h[x]};h[x]=head;}}s;
void con(int x,int y,int w,int g){s.add(x,y,w,g);s.add(y,x,-w,0);}
namespace MCMF{
ll d[N];int g[N],pre[N];
priority_queue<pair<int,int> > Q;
int bfs(){
Me(d,0x3f);d[S]=0;g[S]=1e9;Q.push({0,S});while(!Q.empty()){
auto x=Q.top();Q.pop();if(x.fi!=-d[x.se]) continue;
yyy tmp;for(int i=s.h[x.se];i;i=tmp.z){
tmp=s.f[i];if(!tmp.g||d[tmp.to]<=d[x.se]+tmp.w) continue;pre[tmp.to]=i;
d[tmp.to]=d[x.se]+tmp.w;g[tmp.to]=min(g[x.se],tmp.g);Q.push({-d[tmp.to],tmp.to});
}
}
return d[T]<INF;
}
ll calc(){
ll ans=0;while(bfs()){
ans+=g[T]*d[T];int x=T;while(x^S) s.f[pre[x]].g-=g[T],s.f[pre[x]^1].g+=g[T],x=s.f[pre[x]^1].to;
}
return ans;
}
}
int main(){
int i,j;scanf("%d%d%d",&n,&m,&k);
S=0;T=n+1;for(i=0;i<=n;i++) con(i,i+1,0,k);
for(i=1;i<=m;i++) scanf("%d%d%d",&x,&y,&z),con(x,y+1,-z,1);
printf("%lld\n",-MCMF::calc());
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 14068kb
input:
7 20 5 3 4 1 1 1 1 2 7 1 3 7 1 2 2 1 3 7 1 4 6 1 7 7 1 5 5 1 1 6 1 3 4 1 1 4 1 3 6 1 3 3 1 2 5 1 1 1 1 5 5 1 1 1 1 6 7 1 2 2 1
output:
15
result:
ok "15"
Test #2:
score: 0
Accepted
time: 5ms
memory: 13844kb
input:
12 20 5 5 5 1 8 12 1 4 10 1 10 12 1 2 11 1 3 6 1 6 12 1 1 10 1 4 9 1 7 10 1 4 12 1 2 10 1 1 12 1 4 5 1 4 9 1 7 9 1 3 9 1 10 11 1 6 12 1 4 10 1
output:
10
result:
ok "10"
Test #3:
score: 0
Accepted
time: 2ms
memory: 13872kb
input:
7 20 5 2 7 1 6 6 1 3 6 1 3 3 1 2 5 1 6 6 1 2 6 1 2 7 1 4 6 1 3 3 1 2 2 1 5 5 1 1 4 1 1 5 1 2 5 1 4 4 1 2 7 1 3 4 1 2 4 1 1 2 1
output:
12
result:
ok "12"
Test #4:
score: 0
Accepted
time: 5ms
memory: 14092kb
input:
11 20 5 1 8 1 1 10 1 10 11 1 7 11 1 3 10 1 3 8 1 1 8 1 4 5 1 4 5 1 1 7 1 3 4 1 3 7 1 5 6 1 2 6 1 4 9 1 4 10 1 4 4 1 1 11 1 7 10 1 4 8 1
output:
9
result:
ok "9"
Test #5:
score: 0
Accepted
time: 0ms
memory: 13848kb
input:
8 20 5 6 7 1 4 5 1 1 7 1 3 7 1 1 6 1 3 8 1 1 1 1 2 2 1 1 7 1 3 4 1 6 6 1 1 7 1 1 1 1 1 3 1 4 4 1 8 8 1 3 4 1 1 6 1 6 6 1 2 8 1
output:
13
result:
ok "13"
Test #6:
score: 0
Accepted
time: 2ms
memory: 13880kb
input:
20 20 1 3 14 1 1 17 1 3 18 1 14 20 1 15 17 1 9 17 1 10 12 1 6 20 1 11 16 1 3 17 1 1 2 1 6 19 1 17 18 1 4 18 1 4 9 1 3 7 1 4 13 1 17 19 1 7 12 1 10 14 1
output:
4
result:
ok "4"
Test #7:
score: 0
Accepted
time: 4ms
memory: 13936kb
input:
20 20 2 10 20 1 8 9 1 1 8 1 12 17 1 3 20 1 7 18 1 6 10 1 3 5 1 5 9 1 3 6 1 1 3 1 2 6 1 9 11 1 2 11 1 3 15 1 1 7 1 5 7 1 6 11 1 15 18 1 8 10 1
output:
7
result:
ok "7"
Test #8:
score: 0
Accepted
time: 0ms
memory: 13848kb
input:
20 20 3 3 16 1 6 17 1 8 17 1 11 19 1 5 7 1 3 13 1 16 19 1 6 8 1 3 14 1 7 10 1 6 13 1 1 5 1 4 20 1 16 16 1 8 17 1 7 19 1 12 16 1 5 14 1 10 18 1 10 16 1
output:
7
result:
ok "7"
Test #9:
score: 0
Accepted
time: 5ms
memory: 13876kb
input:
20 20 4 8 19 1 15 19 1 10 20 1 5 11 1 1 2 1 12 15 1 5 7 1 10 14 1 3 6 1 13 19 1 5 10 1 6 7 1 7 7 1 1 19 1 9 16 1 3 16 1 1 2 1 4 20 1 15 16 1 7 11 1
output:
12
result:
ok "12"
Test #10:
score: 0
Accepted
time: 1ms
memory: 13920kb
input:
20 20 5 10 18 1 5 9 1 1 17 1 12 19 1 12 13 1 11 17 1 7 10 1 2 10 1 8 13 1 4 6 1 12 13 1 13 13 1 14 20 1 1 9 1 19 19 1 5 8 1 16 16 1 1 6 1 5 16 1 2 4 1
output:
15
result:
ok "15"
Subtask #2:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
1794 5000 5 419 430 46802829 1071 1140 167141363 1154 1554 366136993 735 1265 152210166 387 1104 646459531 1073 1637 525871859 1340 1729 44303243 1221 1574 588158235 91 478 922877048 1117 1268 460323230 315 1103 378106915 272 1071 784282054 1147 1469 220209516 281 375 514585737 677 1031 231082599 55...
output:
result:
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 451ms
memory: 48448kb
input:
322675 500000 1 162058 177924 125740423 72321 188693 51206015 73706 159883 238256306 223634 241332 292316893 8164 94217 879196279 232892 319246 624760769 67688 195525 319652781 70831 92026 394982900 68675 156743 598333126 107804 308096 843245966 57077 248406 291662171 12794 193657 560389007 105560 2...
output:
2970174438
result:
wrong answer 1st words differ - expected: '480886198651', found: '2970174438'
Subtask #4:
score: 0
Time Limit Exceeded
Test #51:
score: 0
Time Limit Exceeded
input:
194181 500000 5 22921 38709 1 103611 130117 1 33044 135246 1 25161 106036 1 13484 183424 1 129622 133239 1 103905 105727 1 8418 141108 1 5951 145648 1 61392 105830 1 139975 149309 1 47361 59947 1 91598 172246 1 32303 43094 1 72490 170121 1 68502 168603 1 56051 91019 1 106112 129606 1 70776 177996 1 ...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #66:
score: 0
Time Limit Exceeded
input:
265199 500000 5 51732 151507 196279569 1147 251097 325871693 79410 120618 539045634 209514 221950 912376813 44813 147573 616444800 53619 134328 533306546 94940 108466 186490362 42483 236958 489649490 127349 167018 943263893 103970 193784 202963780 197001 221033 210521750 5815 113674 152090319 129972...