QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572496#4209. Stranded Far From Homehansiyuan0 70ms18472kbC++14843b2024-09-18 14:57:022024-09-18 14:57:02

Judging History

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

  • [2024-09-18 14:57:02]
  • 评测
  • 测评结果:0
  • 用时:70ms
  • 内存:18472kb
  • [2024-09-18 14:57:02]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=4e5+5;
int n,m;
int siz[N],fa[N],fail[N];
struct nd{int u,v,w;} e[N];
bool cmp(nd x,nd y){return x.w<y.w;}
int getfa(int x){
	if(x==fa[x]) return x;
	int fath = getfa(fa[x]);
	fail[x] |= fail[fa[x]];
	return fa[x] = fath;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",&siz[i]);
		fa[i] = i;
	}
	for(int i=1;i<=m;i++){
		scanf("%lld%lld",&e[i].u,&e[i].v);
		if(siz[e[i].u]<siz[e[i].v])
			swap(e[i].u,e[i].v);
		e[i].w = siz[e[i].u];
	}
	sort(e+1,e+m+1,cmp);
	for(int i=1;i<=m;i++){
		int x=e[i].u,y=e[i].v;
		int fx=getfa(x),fy=getfa(y);
		if(siz[fy]<siz[fx]) fail[fy]=1;
		siz[fx] += siz[fy];
		fa[fy] = fx;
	}
	for(int i=1;i<=n;i++){
		getfa(i);
		printf("%d",!fail[i]);
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10160kb

input:

1622 1998
29021716 740464354 721037601 759718475 973636178 59068917 294028640 285332651 203821680 397646208 488684783 448548424 565347277 112938323 832704692 837437153 508335516 167646888 798998153 86605661 820823253 705498382 116513873 672806499 522392461 568294614 457655230 647498964 577669416 506...

output:

000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000...

result:

wrong answer 1st lines differ - expected: '011110101110001100101101111110...1000100110101000000111111011011', found: '000000000000000000000000000000...0000000000000000000000000000000'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 10
Accepted
time: 52ms
memory: 17288kb

input:

200000 199999
100000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '100000000000000000000000000000...0000000000000000000000000000000'

Test #16:

score: 0
Wrong Answer
time: 54ms
memory: 16444kb

input:

200000 199999
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 1st lines differ - expected: '111111111111111111111111111111...0000000000000000000000000000000', found: '000000000000000000000000000000...0000000000000000000000000000000'

Subtask #3:

score: 0
Wrong Answer

Test #30:

score: 15
Accepted
time: 70ms
memory: 17152kb

input:

199999 199998
758475118 758475116 758475114 758475112 758475110 758475108 758475106 758475104 758475102 758475100 758475098 758475096 758475094 758475092 758475090 758475088 758475086 758475084 758475082 758475080 758475078 758475076 758475074 758475072 758475070 758475068 758475066 758475064 758475...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...1111111111111111111111111111111'

Test #31:

score: 0
Wrong Answer
time: 65ms
memory: 17116kb

input:

198765 198764
331155986 402813770 954736614 79847944 642540167 755767778 749263519 200053132 274136233 631137603 175636207 109779934 886611000 234477496 562265730 302427246 297486401 72574701 921718778 740910704 341000613 985634966 75658269 782951356 920385380 798515520 757586463 121205584 268860640...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 1st lines differ - expected: '001001100100101110110100111001...0100010100100101101101111011011', found: '000000000000000000000000000000...0000000000000000000000000000000'

Subtask #4:

score: 0
Wrong Answer

Test #39:

score: 0
Wrong Answer
time: 52ms
memory: 18472kb

input:

155555 200000
473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735421 473735...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

wrong answer 1st lines differ - expected: '111111111111111111111111111111...1111111111111111111111111111100', found: '000000000000000000000000000000...0000000000000000000000000000000'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%