QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#399112#8038. Hammer to FallHqwqWA 77ms28428kbC++201.7kb2024-04-25 22:07:292024-04-25 22:07:30

Judging History

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

  • [2024-04-25 22:07:30]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:28428kb
  • [2024-04-25 22:07:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, q, a[100010], b[100010], d[100010], ww[100010], vis[100010];
vector<ll>e[100010], w[100010];
vector<pair<ll,ll>>da[100010];
multiset<ll>s[100010];
const ll mod = 998244353;
int main() {
	scanf("%lld %lld %lld", &n, &m, &q);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	for (ll i = 1; i <= m; i++) {
		ll u, v, www;
		scanf("%lld %lld %lld", &u, &v, &www);
		e[u].push_back(v);
		w[u].push_back(www);
		e[v].push_back(u);
		w[v].push_back(www);
	}
	for (ll i = 1; i <= q; i++) {
		scanf("%lld", &b[i]);
	}
	ll lj = sqrtl(2 * m);
	for (ll i = 1; i <= n; i++) d[i] = e[i].size();
	for (ll i = 1; i <= n; i++) if (d[i] > lj) vis[i] = 1;
	for (ll i = 1; i <= n; i++)
		for (ll j = 0; j < e[i].size();j++)
		{
			if (vis[e[i][j]])
				da[i].push_back({ e[i][j],w[i][j]});
			if (vis[e[i][j]])
				s[i].insert(w[i][j]);
		}
	for (ll i = q; i >= 1; i--) {
		ll x = b[i];
		if (d[x] <= lj) {
			ll minn = 1e18;
			for (ll j = 0; j < d[x]; j++) {
				minn = min(minn, ww[e[x][j]] + w[x][j]);
			}
			for (ll nx : e[x]) {
				if (vis[nx]) {
					s[nx].erase(s[nx].find(ww[x]));
					s[nx].insert(minn);
				}
			}
			ww[x] = minn;
		}
		else {
			ll minn = (*s[x].begin());
			for (pair<ll,ll> nx : da[x]) {
					s[nx.first].erase(s[nx.first].find(ww[x] + nx.second));
					s[nx.first].insert(minn + nx.second);
			}
			ww[x] = minn;
		}
		//for (int i = 1; i <= n; i++)
		//	cout << ww[i] << " \n"[i == n];
	}
	ll ans = 0;
	for (ll i = 1; i <= n; i++)
	{
		//cout << ww[i] << " \n"[i == n];
		ans = (ans + ww[i] % mod * a[i]) % mod;
	}
	cout << ans;
}

详细

Test #1:

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

input:

3 2 2
1 1 1
2 3 10
1 2 1
3 2

output:

12

result:

ok single line: '12'

Test #2:

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

input:

2 1 10
5000 5000
1 2 10000
1 2 2 1 2 2 1 1 1 2

output:

550000000

result:

ok single line: '550000000'

Test #3:

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

input:

10 10 10
5 14 99 14 18 4 58 39 48 60
2 4 4
6 9 56
10 8 34
7 5 96
1 3 26
3 7 92
6 8 4
5 1 72
7 6 39
7 2 93
8 8 9 10 2 2 5 9 2 3

output:

8810

result:

ok single line: '8810'

Test #4:

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

input:

100 500 10000
89 61 65 85 89 2 32 97 13 70 29 86 68 74 84 64 54 39 26 84 56 95 73 11 70 26 60 40 84 58 68 33 65 71 55 2 11 71 49 85 14 59 38 11 60 8 81 78 27 32 52 49 35 94 62 72 64 50 12 45 77 74 92 67 92 38 81 39 12 29 60 70 53 33 25 60 7 83 4 85 47 32 13 58 85 86 44 68 44 1 81 62 97 7 66 62 5 16 ...

output:

609241

result:

ok single line: '609241'

Test #5:

score: 0
Accepted
time: 62ms
memory: 24352kb

input:

100000 100000 100000
134299012 740620432 241626312 533601686 901212368 274154852 46613593 72208460 685661661 930069933 934386896 140544225 900179749 8735320 54649110 922673925 450551589 517879800 773426781 410723403 783459037 344315202 75310230 122339501 113898579 646500753 18238713 119326471 969272...

output:

641103242

result:

ok single line: '641103242'

Test #6:

score: 0
Accepted
time: 77ms
memory: 13180kb

input:

448 100000 100000
411038009 847809848 901622409 143987890 230747977 330204397 58948994 635255827 124637955 446506876 693363517 282765360 687916399 598850473 404480258 958197468 332242997 7338874 321860348 37384562 440321061 434694843 935461053 803393359 852456369 428568442 233194935 663299156 907095...

output:

571525504

result:

ok single line: '571525504'

Test #7:

score: 0
Accepted
time: 57ms
memory: 13840kb

input:

800 100000 100000
251326676 820687742 668136087 685815400 271616099 930730049 622254842 263896849 496882119 842365233 827598659 952040530 71490970 870970052 583387021 380241141 573355930 302234935 73043289 694595013 308355368 412222215 132076042 970688532 157167052 932138361 941436777 33081400 29786...

output:

127243876

result:

ok single line: '127243876'

Test #8:

score: 0
Accepted
time: 37ms
memory: 14920kb

input:

2500 100000 100000
906300804 27973131 291731361 13136711 330409907 278210346 97382525 517930303 140685227 76822227 543248915 363117785 379028542 906572814 130403111 29847389 693506370 592704644 989452223 269178614 114603023 108858627 613364646 303414069 537766403 972627965 512287469 938256271 272592...

output:

922000064

result:

ok single line: '922000064'

Test #9:

score: 0
Accepted
time: 40ms
memory: 15208kb

input:

10000 100000 100000
168611457 237345210 879803481 965771982 336411698 283779723 795910140 511076651 625031271 962687567 982088706 658338866 214250373 76724769 976426858 178997802 124508865 478813203 990810948 918523277 15520937 320075177 818778935 449094027 979791260 335062620 345893885 601632901 55...

output:

984915144

result:

ok single line: '984915144'

Test #10:

score: 0
Accepted
time: 19ms
memory: 9528kb

input:

100 4950 100000
390 243 931 295 750 711 295 425 192 904 175 450 715 602 708 456 905 791 996 606 401 330 168 218 55 635 989 349 571 502 243 6 566 435 913 759 432 375 535 382 973 234 978 861 931 224 131 435 853 184 649 897 259 200 218 406 48 710 38 132 579 896 388 800 926 558 59 365 682 475 867 898 51...

output:

49445093

result:

ok single line: '49445093'

Test #11:

score: 0
Accepted
time: 3ms
memory: 8572kb

input:

10 5 1000
15 4 4 5 16 2 11 11 2 10
1 3 10
6 4 18
8 9 18
7 2 18
10 5 20
1 4 2 3 7 7 7 8 9 10 8 1 7 2 6 7 3 6 7 8 3 10 10 2 6 6 1 9 9 3 8 1 8 6 5 8 7 3 3 4 7 6 7 1 8 5 2 3 5 5 7 4 6 3 2 5 9 4 5 1 2 9 4 5 5 2 6 4 5 3 5 4 10 1 10 3 1 1 8 5 2 4 2 5 6 7 6 4 1 9 9 2 4 3 4 10 6 3 4 1 1 3 2 2 8 6 2 8 1 10 6 ...

output:

131690

result:

ok single line: '131690'

Test #12:

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

input:

7 14 10
291114498 673454859 532789761 628672010 833068294 412154083 525136251
3 5 92
4 1 57
7 3 90
2 3 96
6 7 81
6 3 100
6 1 71
2 4 76
2 1 97
6 4 73
2 7 97
6 5 87
2 5 100
6 2 5
6 2 2 6 6 2 2 2 2 6

output:

813329136

result:

ok single line: '813329136'

Test #13:

score: 0
Accepted
time: 52ms
memory: 23688kb

input:

40100 100000 100000
449328284 205410501 451233745 662762857 523774778 505289571 175281968 29821532 289051457 816202892 747849082 152467876 27551719 333462510 816680538 34877361 338141803 468189401 791444416 449513175 687791246 759960262 997873759 330313678 319983381 63035341 177327150 337347635 9634...

output:

901232016

result:

ok single line: '901232016'

Test #14:

score: -100
Wrong Answer
time: 55ms
memory: 28428kb

input:

100000 100000 100000
573792977 201480175 45235867 914202012 246841206 701877700 703821119 37152009 575319618 930506992 703290810 881010700 63914136 96962139 933233795 280963567 671736608 908116432 365397906 284762912 171633220 5053568 330355941 56753074 824456884 854049151 181984509 289214427 855131...

output:

0

result:

wrong answer 1st lines differ - expected: '301752872', found: '0'