QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282270#1359. Setting MapszhichengWA 1ms11948kbC++142.1kb2023-12-11 17:18:492023-12-11 17:18:49

Judging History

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

  • [2023-12-11 17:18:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:11948kb
  • [2023-12-11 17:18:49]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2010,M=2000010;
int n,tot=1,minu,maxu,vis[N],cur[N],lev[N],src,des,first[N],nnext[M],to[M];
ll w[M],ww[M];
queue<int>q;
vector<int>anss;
void add(int x,int y,ll z){
	nnext[++tot]=first[x];
	first[x]=tot;
	to[tot]=y;
	w[tot]=z;
}
bool bfs(){
	int u;
	while(!q.empty()){
		q.pop();
	}
	for(int i=minu;i<=maxu;i++){
		cur[i]=first[i];
		lev[i]=-1;
	}
	lev[src]=0;
	q.push(src);
	while(!q.empty()){
		u=q.front();
		q.pop();
		for(int e=first[u];e;e=nnext[e]){
			if(w[e]&&lev[to[e]]==-1){
				lev[to[e]]=lev[u]+1;
				q.push(to[e]);
				if(to[e]==des){
					return 1;
				}
			}
		}
	}
	return 0;
}
ll dinic(int u,ll flow){
	ll res=0,delta;
	if(u==des){
		return flow;
	}
	if(u%(n*2)==des%(n*2)&&flow){
		printf("-1");
		exit(0);
	}
	for(int &e=cur[u];e;e=nnext[e]){
		if(w[e]&&lev[to[e]]>lev[u]){
			delta=dinic(to[e],min(flow-res,w[e]));
			if(delta){
				w[e]-=delta;
				w[e^1]+=delta;
				res+=delta;
				if(flow==res){
					break;
				}
			}
		}
	}
	if(flow!=res){
		lev[u]=-1;
	}
	return res;
}
void dfs(int u){
	vis[u]=1;
	for(int e=first[u];e;e=nnext[e]){
		if(!vis[to[e]]&&w[e]>0){
			dfs(to[e]);
		}
	}
}
int main(){
	int m,k,a,b,pp=0;
	ll ans=0;
	scanf("%d%d%d%d%d",&n,&m,&k,&src,&des);
	minu=1;
	maxu=n*2*k;
	des+=(k-1)*n*2+n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		for(int j=1;j<=k;j++){
			add((j-1)*2*n+i,(j-1)*2*n+i+n,a);
			add((j-1)*2*n+i+n,(j-1)*2*n+i,0);
		}
	}
	while(m--){
		scanf("%d%d",&a,&b);
		for(int i=1;i<=k;i++){
			add((i-1)*2*n+a+n,(i-1)*2*n+b,1e18);
			add((i-1)*2*n+b,(i-1)*2*n+a+n,0);
		}
	}
	for(int i=1;i<=k-1;i++){
		for(int j=1;j<=n;j++){
			add((i-1)*2*n+j,i*2*n+j+n,1e18);
			add(i*2*n+j+n,(i-1)*2*n+j,0);
		}
	}
	while(bfs()){
		ans+=dinic(src,1e18);
		pp=1;
	}
	if(!pp||ans==1e18){
		printf("-1");
		return 0;
	}
	dfs(src);
	for(int i=1;i<=n*2*k;i++){
		for(int e=first[i];e;e=nnext[e]){
			if(vis[i]&&!vis[to[e]]&&to[e]==i+n&&w[e]==0){
				anss.push_back(i%(n*2));
			}
		}
	}
	printf("%d\n",anss.size());
	for(auto i:anss){
		printf("%d ",i);
	}
}

详细

Test #1:

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

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

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

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

input:

2 2 2
2 1
100 200
1 2
2 1

output:

2
2 1 

result:

ok answer = 300

Test #5:

score: 0
Accepted
time: 1ms
memory: 10192kb

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

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

input:

2 1 5
1 2
10 10
1 2

output:

-1

result:

ok answer = IMPOSSIBLE

Test #8:

score: 0
Accepted
time: 0ms
memory: 9992kb

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
67 7 

result:

ok answer = 20000000

Test #9:

score: 0
Accepted
time: 1ms
memory: 9984kb

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

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

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

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
174 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 ...

result:

ok answer = 2000000000

Test #13:

score: 0
Accepted
time: 1ms
memory: 9964kb

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
42 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 102...

result:

ok answer = 2000000000

Test #14:

score: 0
Accepted
time: 1ms
memory: 9988kb

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

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

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

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
34 

result:

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