QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#77625#1359. Setting MapsCharlieVinnieWA 3ms3772kbC++233.1kb2023-02-15 10:36:282023-02-15 10:36:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-15 10:36:30]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3772kb
  • [2023-02-15 10:36:28]
  • 提交

answer

#include "bits/stdc++.h"
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
#define assume(expr) ((!!(expr))||(exit((fprintf(stderr,"Assumption Failed: %s on Line %d\n",#expr,__LINE__),-1)),false))
using namespace std;
// N is the number of vertices, M is the number of edges you're about to add
// cst_type is what you think it is
template<int N,int M,typename cst_type=int>
class Dinic{
    int n,S,T,head[N],nxt[M*2],to[M*2],tot,q[N],h,t,dep[N],now[N]; cst_type cap[M*2],maxflow;
    bool bfs(){
        h=t=0; q[t++]=S; For(i,1,n) dep[i]=0; ; dep[S]=1; now[S]=head[S];
        while(h<t){
            int u=q[h++]; for(int e=head[u];e;e=nxt[e]){
                if(cap[e]==0) continue; ; int v=to[e];
                if(!dep[v]) { dep[v]=dep[u]+1; now[v]=head[v]; q[t++]=v; if(v==T) return true; }
            }
        } return false;
    }
    cst_type dfs(int u,cst_type flow){
        if(u==T) return flow; ; cst_type fw=0;
        for(int& e=now[u];e;e=nxt[e]){
            if(cap[e]==0) continue; ; int v=to[e]; if(dep[v]!=dep[u]+1) continue;
            cst_type res=dfs(v,min(flow,cap[e])); if(res==0) { dep[v]=0; continue; }
            cap[e]-=res; cap[e^1]+=res; fw+=res; flow-=res; if(flow==0) break;
        } return fw;
    }
public:
    void init(int _n) { n=_n; tot=1; } 
    void clear(int _n) { For(i,1,n) head[i]=0; ; maxflow=0; n=_n; tot=1; }
    int add_edge(int x,int y,cst_type z) { nxt[++tot]=head[x]; head[x]=tot; to[tot]=y; cap[tot]=z; nxt[++tot]=head[y]; head[y]=tot; to[tot]=x; cap[tot]=0; return tot-1; }
    cst_type solve(int _S,int _T,cst_type inf=numeric_limits<cst_type>::max()){
        if(!n||tot%2==0) { cerr<<"INIT YOUR DINIC!!!!!!!!!!!!"<<endl; exit(-1); }
        S=_S; T=_T; while(bfs()) { cst_type res=-1; while((res=dfs(S,inf))!=0) maxflow+=res; } ; return maxflow;
    }
    cst_type flowing(int e) { return cap[e^1]; }
    vector<int> get_cut() { bfs(); vector<int> res; for(int e=2;e<=tot;e+=2) if(dep[to[e^1]]&&!dep[to[e]]) res.push_back(e); ; return res; }
};
const int N=205,M=505; typedef long long ll;
Dinic<N*5*2,M*5+N*5*2,ll> G;
int n,m,__ssa,K,S0,T0,a[N],in[N][6],out[N][6],ncnt,id[N*12];
signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>m>>K>>S0>>T0; __ssa=1; For(i,1,n) cin>>a[i],__ssa+=a[i];; For(i,1,n) For(j,0,K-1) in[i][j]=++ncnt,out[i][j]=++ncnt;
    G.init(ncnt); For(i,1,n) { For(j,0,K-1) id[G.add_edge(in[i][j],out[i][j],a[i])]=i;; For(j,0,K-2) G.add_edge(in[i][j],out[i][j+1],__ssa); }
    For(j,0,K-2) G.add_edge(out[T0][j],out[T0][j+1],__ssa);; For(i,1,m) { int x,y; cin>>x>>y; For(j,0,K-1) G.add_edge(out[x][j],in[y][j],__ssa); }
    ll res=G.solve(in[S0][0],out[T0][K-1]); 
    // printf("res=%lld\n",res);
    if(res>=__ssa) cout<<"-1\n",exit(0);
    vector<int> Cut=G.get_cut(); cout<<Cut.size()<<'\n'; for(int c:Cut) cout<<id[c]<<' ';; cout<<'\n';
    cerr<<"Time = "<<clock()<<" ms"<<endl;
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3412kb

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: 3532kb

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: 0ms
memory: 3628kb

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: 3428kb

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: 0ms
memory: 3412kb

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: 2ms
memory: 3512kb

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: 2ms
memory: 3440kb

input:

2 1 5
1 2
10 10
1 2

output:

-1

result:

ok answer = IMPOSSIBLE

Test #8:

score: 0
Accepted
time: 2ms
memory: 3608kb

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: 2ms
memory: 3640kb

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: 2ms
memory: 3576kb

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: 2ms
memory: 3604kb

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: 2ms
memory: 3576kb

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: 2ms
memory: 3652kb

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: 0ms
memory: 3620kb

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: 3560kb

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: 3652kb

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: 2ms
memory: 3524kb

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: 2ms
memory: 3560kb

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: 2ms
memory: 3576kb

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: 0ms
memory: 3552kb

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: 1ms
memory: 3536kb

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: 0ms
memory: 3560kb

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: 0ms
memory: 3544kb

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: 3688kb

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: 2ms
memory: 3516kb

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: 2ms
memory: 3712kb

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: -100
Wrong Answer
time: 3ms
memory: 3772kb

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:

34
7 30 33 36 38 43 44 49 50 52 65 73 80 89 92 102 112 113 117 119 126 127 138 143 154 155 158 159 167 169 171 177 183 186 

result:

wrong answer Given vertex set from user output does not cover k vertices in some path