QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#110099 | #1359. Setting Maps | c20230135 | WA | 5ms | 11956kb | C++14 | 2.8kb | 2023-05-31 15:24:37 | 2023-05-31 15:24:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int R = 205, K = 6, N = 1000005, M = 2000005;
const ll inf = 1e10 + 5;
int n, m, k, cnt, tot = 1, st, ed, s, t, num;
int in[R][K], out[R][K];
int fir[N], ver[M], nxt[M], d[N], v[N], ans[R];
ll edge[M], c[R], flow, mincut;
void add(int x, int y, ll z) {
ver[++tot] = y, edge[tot] = z, nxt[tot] = fir[x], fir[x] = tot,
ver[++tot] = x, edge[tot] = 0, nxt[tot] = fir[y], fir[y] = tot;
}
bool bfs() {
queue<int> q;
for (int i = 1; i <= cnt; i++) d[i] = 0;
while (q.size()) q.pop();
q.push(s), d[s] = 1;
while (!q.empty()) {
int x = q.front(); q.pop();
for (int i = fir[x]; i; i = nxt[i]) {
int y = ver[i];
if (d[y] || !edge[i]) continue;
d[y] = d[x] + 1;
q.push(y);
if (y == t) return true;
}
}
return false;
}
ll dinic(int x, ll flow) {
if (x == t) return flow;
ll rst = flow;
for (int i = fir[x]; i && rst; i = nxt[i]) {
int y = ver[i];
if (edge[i] && d[y] == d[x] + 1) {
ll k = dinic(y, min(rst, edge[i]));
if (!k) d[y] = 0;
edge[i] -= k;
edge[i ^ 1] += k;
rst -= k;
}
}
return flow - rst;
}
int main() {
//~ scanf("%d%d%d%d%d", &n, &m, &k, &st, &ed);
//~ for (int i = 1; i <= n; i++) {
//~ for (int j = 0; j < k; j++)
//~ in[i][j] = ++cnt, out[i][j] = ++cnt;
//~ }
//~ s = ++cnt, t = ++cnt; add(s, in[st][0], inf);
//~ for (int j = 0; j < k; j++) add(out[ed][j], t, inf);
//~ for (int i = 1; i <= n; i++) {
//~ scanf("%d", &c[i]);
//~ for (int j = 0; j < k; j++)
//~ add(in[i][j], out[i][j], c[i]);
//~ }
//~ for (int i = 1; i <= n; i++) {
//~ for (int j = 0; j < k - 1; j++)
//~ add(in[i][j], out[i][j + 1], inf);
//~ }
//~ for (int x, y, i = 1; i <= m; i++) {
//~ scanf("%d%d", &x, &y);
//~ for (int j = 0; j < k; j++)
//~ add(out[x][j], in[y][j], inf);
//~ }
scanf("%d%d%d%d%d",&n,&m,&k,&st,&ed);
for(ll i=1;i<=n;i++){
for(ll j=0;j<k;j++){
in[i][j]=++cnt;
out[i][j]=++cnt;
}
}
s=++cnt,t=++cnt;
add(s,in[st][0],inf);
for(ll i=0;i<k;i++){
add(out[ed][i],t,inf);
}
for(ll i=1;i<=n;i++){
scanf("%lld",&c[i]);
for(ll j=0;j<k;j++)add(in[i][j],out[i][j],c[i]);
for(ll j=0;j<k-1;j++)add(in[i][j],out[i][j+1],inf);
//如果说这条边c_i跑满了,就表明放了一个点,状态转移
}
for(ll i=1;i<=m;i++){
ll x,y;
scanf("%lld%lld",&x,&y);
for(ll j=0;j<k;j++){
add(out[x][j],in[y][j],inf);
}
}
while (bfs()) while ((flow = dinic(s, inf))) mincut += flow;
//~ printf("mincut = %lld\n", mincut);
if (mincut >= inf) return printf("-1"), 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < k; j++) {
if (d[in[i][j]] > d[out[i][j]]) { ans[++num] = i; break; }
}
}
printf("%d\n", num);
for (int i = 1; i <= num; i++) printf("%d ", ans[i]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 9720kb
input:
3 2 5 1 3 1 60 35 1 2 2 3
output:
-1
result:
ok answer = IMPOSSIBLE
Test #2:
score: 0
Accepted
time: 1ms
memory: 11772kb
input:
7 11 1 1 7 100 5 7 16 11 12 100 1 2 1 3 1 4 1 5 2 3 2 6 3 6 4 3 4 7 5 7 6 7
output:
4 2 3 4 5
result:
ok answer = 39
Test #3:
score: 0
Accepted
time: 3ms
memory: 11848kb
input:
11 17 2 1 11 1000 10 10 10 10 10 10 10 10 10 1000 1 2 1 3 1 4 1 5 1 6 2 7 3 7 4 7 5 8 6 8 7 8 7 9 7 10 8 9 8 11 9 11 10 11
output:
6 5 6 7 8 9 10
result:
ok answer = 60
Test #4:
score: 0
Accepted
time: 2ms
memory: 11796kb
input:
2 2 2 2 1 100 200 1 2 2 1
output:
2 1 2
result:
ok answer = 300
Test #5:
score: 0
Accepted
time: 1ms
memory: 9716kb
input:
5 5 5 1 5 1 1 1 1 1 1 2 2 3 3 4 4 5 1 5
output:
-1
result:
ok answer = IMPOSSIBLE
Test #6:
score: 0
Accepted
time: 3ms
memory: 9812kb
input:
100 120 5 1 5 5367720 2854323 1799056 9744604 3215334 7580413 6269402 3208439 8812449 3297484 2047196 4044341 7514502 2928715 9335004 3935096 6660663 3356480 4801491 5786147 895995 6710240 222342 4469390 1543213 6678041 8838445 6741919 8138951 5273670 8983795 5131484 4245746 7460466 8357966 8464419 ...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #7:
score: 0
Accepted
time: 3ms
memory: 9724kb
input:
2 1 5 1 2 10 10 1 2
output:
-1
result:
ok answer = IMPOSSIBLE
Test #8:
score: 0
Accepted
time: 4ms
memory: 11908kb
input:
154 304 2 67 7 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 100000...
output:
2 7 67
result:
ok answer = 20000000
Test #9:
score: 0
Accepted
time: 1ms
memory: 11832kb
input:
75 146 1 15 2 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 1000000...
output:
1 15
result:
ok answer = 10000000
Test #10:
score: 0
Accepted
time: 0ms
memory: 9760kb
input:
182 360 4 97 110 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 1000...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #11:
score: 0
Accepted
time: 0ms
memory: 9764kb
input:
136 268 5 132 5 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #12:
score: 0
Accepted
time: 4ms
memory: 11828kb
input:
200 396 3 174 124 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 100...
output:
200 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
result:
ok answer = 2000000000
Test #13:
score: 0
Accepted
time: 4ms
memory: 11864kb
input:
200 396 3 42 18 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000...
output:
200 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
result:
ok answer = 2000000000
Test #14:
score: 0
Accepted
time: 2ms
memory: 9808kb
input:
37 399 5 5 35 891013 857886 463822 491619 5700997 373660 280470 331195 292218 4060 330862 140381 522628 931507 600262 414267 639018 496399 286724 783899 792123 775919 981183 469461 229242 320358 970309 811929 818205 630620 209749 899622 339790 483597 7328305 375252 241902 37 32 26 25 31 37 11 25 35 ...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #15:
score: 0
Accepted
time: 0ms
memory: 11824kb
input:
43 447 4 23 5 410445 107466 417812 818439 7500390 767395 955105 835303 417635 40481 687217 129693 686787 546514 598770 645791 239755 22583 513445 243544 454644 619458 8758220 584039 864849 479006 85516 734429 997123 561319 900136 750915 22210 812718 315780 263441 639259 543094 40967 109688 857581 71...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #16:
score: 0
Accepted
time: 2ms
memory: 9812kb
input:
94 454 4 10 37 686254 113102 198921 108527 245692 298529 730688 309868 250532 7757813 223044 866362 685371 924303 328789 529482 811273 239786 73318 495070 857739 562195 586139 625871 776305 557501 798290 742600 350241 584299 26519 305673 678898 992953 656558 268773 9023461 10388 431117 542020 928225...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #17:
score: 0
Accepted
time: 3ms
memory: 9748kb
input:
69 415 5 34 13 187979 21011 558124 591620 617581 886091 755733 454183 48557 77690 663115 689272 6523235 47643 93831 636058 841310 272665 181270 75938 161738 713173 360987 182941 884235 664804 382347 462472 55249 646350 558127 66134 823777 5017391 738022 598894 643281 584923 5728 719403 528781 287123...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #18:
score: 0
Accepted
time: 3ms
memory: 9764kb
input:
74 410 5 56 20 488488 698144 373082 803224 42941 35786 251834 295325 310693 453121 656518 876704 468532 536212 395433 621720 64467 814721 93928 8845346 519676 871614 340758 843970 729408 449075 751325 413222 556993 705853 943484 700768 640760 765293 197380 348204 584112 9735 76698 324024 536009 3061...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #19:
score: 0
Accepted
time: 3ms
memory: 9780kb
input:
112 475 5 77 14 458807 862988 747050 549161 272433 613321 283502 255018 225146 161415 101246 246922 750336 5181286 66176 340232 996869 865175 206322 151130 137565 684082 341281 334633 841523 356897 991731 533584 380228 849451 189214 56801 683298 25418 383598 768288 551730 556269 737795 271814 323695...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #20:
score: 0
Accepted
time: 1ms
memory: 9724kb
input:
119 484 5 11 32 165598 630106 823509 869781 685441 742597 915091 659432 634290 175760 5311972 639237 255082 203370 950415 872349 181092 451235 734695 622085 432676 505268 968125 789747 136429 166389 9290 176005 262474 551589 350471 7478302 783302 603239 559669 687158 26612 369279 547990 78403 15335 ...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #21:
score: 0
Accepted
time: 3ms
memory: 9784kb
input:
142 375 5 116 104 63599 894199 604295 332052 288396 916080 30248 354232 445633 440305 374406 981920 863467 569323 441073 586879 682410 493748 530620 375855 906213 44552 558142 127276 896643 254275 258514 292884 633970 418024 477079 849005 885347 922653 969968 752223 964300 152813 696644 61238 79525 ...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #22:
score: 0
Accepted
time: 3ms
memory: 9856kb
input:
183 487 4 160 104 861248 114428 458126 590856 434607 175599 497335 415522 5210 543525 358378 651065 795806 77245 262676 791440 800664 515963 187174 791630 577197 405448 310869 790587 273155 998576 784475 349319 645638 980898 825396 921220 776036 809716 680739 298663 103377 526237 912938 251723 15232...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #23:
score: 0
Accepted
time: 1ms
memory: 9800kb
input:
200 499 4 63 61 840236 200242 748905 993501 756897 832236 310561 724047 795114 972430 614472 303292 528099 983661 904724 998052 831483 874832 545487 687161 79029 583414 108438 145634 201003 296143 58522 233209 757702 862078 269858 501581 318663 387614 269896 806625 523906 987641 765239 153963 228254...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #24:
score: 0
Accepted
time: 1ms
memory: 9824kb
input:
150 374 5 113 129 963484 390638 959395 95619 548927 978322 307668 617709 949256 5435 502970 513103 636082 90166 226330 173776 162221 287649 574318 187625 429914 750641 787872 511271 627856 681261 633555 517549 938395 275120 558362 43248 239223 370347 191039 614969 1817 207776 297662 526119 337127 49...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #25:
score: 0
Accepted
time: 1ms
memory: 9840kb
input:
176 131 5 47 118 431659 989353 962218 363659 988302 933830 26769 460320 590689 887733 328107 362131 831900 629028 261988 606418 812284 689190 910954 311346 746819 919793 175473 488620 7030 857310 989872 927131 736414 500269 390114 828223 893320 431934 572166 687804 590341 326808 138848 364508 215467...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #26:
score: 0
Accepted
time: 0ms
memory: 9804kb
input:
200 494 5 28 5 143725 965366 545804 656307 8059164 74371 472455 439180 179926 743420 742454 930313 936719 83635 150734 836620 254600 252025 157157 565370 992891 832679 358393 958331 70918 561942 287145 5395471 721066 414374 557625 207539 738895 924411 530195 153167 818558 426299 654081 667595 719269...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #27:
score: 0
Accepted
time: 1ms
memory: 9796kb
input:
198 392 5 31 30 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #28:
score: 0
Accepted
time: 1ms
memory: 9816kb
input:
196 388 5 50 11 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 9999997 10000000 10000000 10000000 10000000 10000000 10000000 10000000 100000...
output:
-1
result:
ok answer = IMPOSSIBLE
Test #29:
score: -100
Wrong Answer
time: 5ms
memory: 11956kb
input:
198 392 5 89 127 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 9999998 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000...
output:
84 1 2 8 12 15 16 19 22 26 30 35 38 39 40 42 43 46 47 48 52 53 54 55 57 58 59 67 70 73 76 77 79 82 86 87 88 89 90 92 93 97 98 101 102 105 106 111 112 113 115 117 119 122 126 127 132 137 138 139 143 144 147 148 150 151 152 154 155 158 161 163 165 170 172 173 177 178 180 183 184 189 190 192 195
result:
wrong answer User answer is not optimal; judge: 819999994, user: 839999994