QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772344#6342. Security Guard275307894a12 54ms27356kbC++142.0kb2024-11-22 18:53:482024-11-22 18:53:49

Judging History

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

  • [2024-11-22 18:53:49]
  • 评测
  • 测评结果:12
  • 用时:54ms
  • 内存:27356kb
  • [2024-11-22 18:53:48]
  • 提交

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 fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=4e5+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,Q,A[N],id[N];
vector<int> S[N];
int fa[N],w[N];
int GF(int x){return fa[x]^x?fa[x]=GF(fa[x]):x;}
struct edge{
	int x,y,w;
	bool operator <(const edge &B)const{return w<B.w;}
}e[N];
int eh;
ll ans[N];
void Solve(){
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=m;i++) scanf("%d%d",&e[i].x,&e[i].y),e[i].w=A[e[i].x]+A[e[i].y];
	sort(e+1,e+m+1);
	iota(fa+1,fa+n+1,1);
	copy(A+1,A+n+1,w+1);
	vector<int> val;
	int mi=*min_element(A+1,A+n+1);
	for(int i=1;i<=m;i++){
		auto [u,v,z]=e[i];
		u=GF(u);v=GF(v);
		if(u^v){
			val.push_back(z-max(w[u],w[v])-mi);
			fa[u]=v;w[v]=min(w[u],w[v]);
		}
	}
	ans[n-1]=*max_element(A+1,A+n+1)+mi*(n-2);
	for(int i=n;i<=Q;i++) ans[i]=ans[i-1];
	sort(all(val));
	for(int i=n-1;i;i--) ans[i-1]=ans[i]+val[n-1-i];
	for(int i=0;i<=Q;i++) printf("%lld\n",ans[i]);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 35ms
memory: 26540kb

input:

200000 199999 0
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 1 1 1 1 ...

output:

199999

result:

ok 1 number(s): "199999"

Test #2:

score: 12
Accepted
time: 31ms
memory: 20600kb

input:

200000 199999 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

399998

result:

ok 1 number(s): "399998"

Test #3:

score: 12
Accepted
time: 53ms
memory: 26520kb

input:

200000 199999 0
1 2 1 1 1 2 2 1 2 1 1 2 2 2 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 2 2 1 2 1 1 2 1 2 2 2 2 1 2 2 1 2 1 2 2 2 1 1 1 2 1 1 1 2 2 1 1 1 2 2 2 2 1 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 1 1 2 2 2 1 2 1 1 1 2 1 2 2 2 1 2 1 1 1 1 2 2 1 1 2 1 2 1 2 1 2 ...

output:

299700

result:

ok 1 number(s): "299700"

Test #4:

score: 12
Accepted
time: 25ms
memory: 26568kb

input:

200000 199999 0
2 2 1 2 1 2 2 2 1 1 2 2 1 2 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 1 1 1 2 2 1 2 2 2 2 1 2 1 2 2 1 1 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 1 1 2 1 1 1 1 2 1 1 1 2 2 2 2 1 2 2 2 1 1 1 2 1 2 2 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 2 2 2 2 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 2 2 1 2 1 1 ...

output:

300131

result:

ok 1 number(s): "300131"

Test #5:

score: 12
Accepted
time: 36ms
memory: 26892kb

input:

200000 199999 0
1 2 2 1 1 1 1 2 2 1 2 2 1 2 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 2 2 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 2 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 2 2 2 2 2 1 2 2 2 1 2 2 1 1 2 2 2 1 2 2 2 1 1 2 1 2 2 2 1 2 2 1 2 1 1 2 1 2 2 2 1 2 1 1 1 1 2 1 1 1 2 1 2 2 2 1 2 2 1 2 1 1 1 1 1 2 1 1 2 1 2 1 1 2 2 2 2 ...

output:

300132

result:

ok 1 number(s): "300132"

Test #6:

score: 12
Accepted
time: 33ms
memory: 26800kb

input:

200000 199999 0
2 1 1 2 2 2 1 1 2 2 1 2 2 2 1 1 1 2 1 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 1 1 1 1 2 1 2 2 2 2 1 1 1 1 2 2 2 1 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 1 2 2 1 2 2 1 1 1 2 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 1 2 2 2 2 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 ...

output:

300094

result:

ok 1 number(s): "300094"

Test #7:

score: 12
Accepted
time: 5ms
memory: 20392kb

input:

2 1 0
2 1
1 2

output:

2

result:

ok 1 number(s): "2"

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #8:

score: 13
Accepted
time: 54ms
memory: 27260kb

input:

200000 199999 0
888688136 635144878 255996991 457498818 501986248 161166265 760280211 255673948 435333678 521749421 41382586 784453705 702026010 746126 770719498 150796793 890458633 167539898 952822340 613539963 472897894 866040523 778440023 870323479 702145156 736556675 190255428 993487185 74569854...

output:

99991732542677

result:

ok 1 number(s): "99991732542677"

Test #9:

score: 0
Wrong Answer
time: 31ms
memory: 27356kb

input:

200000 199999 0
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 100000000...

output:

-447105536

result:

wrong answer 1st numbers differ - expected: '199999000000000', found: '-447105536'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #85:

score: 8
Accepted
time: 14ms
memory: 23880kb

input:

16 15 200000
692461146 622302385 805066691 422290641 600839873 940930580 873147413 489653843 239129952 383473127 21389393 913787109 856138328 859082963 262475462 327598064
6 13
6 9
6 15
6 14
6 16
6 8
5 6
1 6
4 6
3 6
6 11
6 7
6 10
2 6
6 12

output:

14113958700
13194417513
12274876326
11355335139
10435793952
9516252765
8596711578
7677170391
6757629204
5838088017
4918546830
3999005643
3079464456
2159923269
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
1240382082
124038208...

result:

ok 200001 numbers

Test #86:

score: 8
Accepted
time: 11ms
memory: 25200kb

input:

16 30 200000
598416543 514756774 234373059 730937929 122327909 710993525 792876211 799558122 542631332 104191856 970044163 3056707 549900459 673639701 722811840 543231107
3 8
1 11
11 15
6 11
8 9
11 16
3 9
11 14
1 14
4 10
5 13
2 7
6 14
6 16
8 11
4 7
9 11
1 12
7 11
2 8
4 11
10 15
7 15
7 9
4 13
4 8
8 1...

output:

9458406784
8049967296
6774121792
5618668020
4780322608
3983821193
3388461357
2848286957
2308712332
1797012265
1565695913
1334379561
1215108359
1113973210
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
1012838061
101...

result:

ok 200001 numbers

Test #87:

score: 8
Accepted
time: 11ms
memory: 24452kb

input:

16 30 200000
774601616 692485693 967189834 429259832 296426891 316821928 86524126 747982494 512308631 846796963 29105202 820501606 172881883 311680540 1017592 456179547
10 12
9 15
2 3
3 9
3 12
7 10
4 10
2 4
8 12
1 8
8 11
6 12
8 13
2 12
5 12
5 8
5 13
9 16
1 13
3 7
1 10
3 10
3 8
5 11
2 8
4 14
8 10
1 3...

output:

7806648343
6357272672
5004346203
4040987540
3221503526
2710212487
2281970247
1971307299
1675898000
1380488701
1208624410
1123117876
1037611342
1009523732
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436122
981436...

result:

ok 200001 numbers

Test #88:

score: 0
Wrong Answer
time: 13ms
memory: 24500kb

input:

16 30 200000
778371010 767069427 941062305 89063818 711136260 375917573 291138067 818518266 339489675 650318923 825989668 527404124 765656766 680039114 528016099 175440720
2 8
12 13
9 16
2 14
5 8
4 6
8 10
3 11
6 8
9 10
2 13
7 8
2 12
1 3
1 5
6 12
8 13
8 12
6 13
1 14
8 11
2 6
8 14
8 15
3 8
1 2
1 13
1 ...

output:

4889580861
3685248210
2955793762
2226339314
1537032122
847724930
169719321
-353400491
-792352772
-1079206527
-1366060282
-1616486139
-1818560388
-2020634637
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539
-2107011539...

result:

wrong answer 1st numbers differ - expected: '9184548157', found: '4889580861'

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%