QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#255561#5540. City Hallsentheta#WA 173ms21204kbC++201.9kb2023-11-18 16:20:082023-11-18 16:20:08

Judging History

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

  • [2023-11-18 16:20:08]
  • 评测
  • 测评结果:WA
  • 用时:173ms
  • 内存:21204kb
  • [2023-11-18 16:20:08]
  • 提交

answer

	#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define int long long
#define pii pair<int,int>
#define pb emplace_back
#define rep(i,a,b) for(int i=a; i < b; ++i)
#define owo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define cerr if(1) cout
#define dbg(x) cerr << "?" << #x << " : " << x << endl;

void solve();
signed main(){
	owo
	int t = 1; //cin >> t
	while(t--) solve();
}

double dist[100005][2];
vector<int> adj[100005];

void solve(){
	int n, m, s, t; cin >> n >> m >> s >> t;
	vector<int> H(n + 1);
	for(int i = 1; i <= n; ++i){
		cin >> H[i];
		dist[i][0] = dist[i][1] = 1e18;
	}
	dist[s][0] = dist[s][1] = 0;
	for(int i = 1; i <= m; ++i){
		int u, v; cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	priority_queue<pair<double ,pii>, vector<pair<double, pii>>, greater<pair<double, pii>>> pq;
	pq.push(make_pair(0, pii(s, 0)));
	while(pq.size()){
		auto [d, P] = pq.top();
		pq.pop();
		auto [u, p] = P;
		if(u < 0 && d > dist[-u][1]) continue;
		if(u < 0 && d <= dist[-u][1]){
			for(auto v:adj[-u]){
				double w = H[-u] - H[v];
				w *= w;
				if(w + d < dist[v][1]){
					dist[v][1] = w + d;
					pq.push(make_pair(dist[v][1], pii(-v, u)));
				}
			}
			continue;
		}
		double tw = (H[u] - H[p]);
		tw *= tw;
		if(d <= dist[u][0]){
			for(auto v:adj[u]){
				double w = H[u] - H[v];
				w *= w;
				if(w + d < dist[v][0]){
					dist[v][0] = w + d;
					dist[v][1] = min(dist[v][1], w + d);
					pq.push(make_pair(dist[v][0], pii(v, u)));
				}
			}
		}
		if(d - tw <= dist[p][0]){
			for(auto v:adj[u]){
				double w = (H[p] - H[v]);
				w *= w;
				w /= 2.0;
				double w2 = H[u] - H[v];
				w2 *= w2;
				double nd = min(dist[u][0], min(w, w2) + dist[p][0]);
				if(nd < dist[v][1]){	
					dist[v][1] = nd;	
					pq.push(make_pair(dist[v][1], pii(-v, u)));
				}
			}
		}
	}
	cout << fixed << setprecision(6) << dist[t][1] << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7108kb

input:

5 6 1 3
5 100 8 2 10
1 2
2 3
2 5
1 4
4 5
3 5

output:

4.500000

result:

ok found '4.5000000', expected '4.5000000', error '0.0000000'

Test #2:

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

input:

5 5 1 5
1 2 10 10 4
1 2
2 3
2 4
3 5
4 5

output:

3.000000

result:

ok found '3.0000000', expected '3.0000000', error '0.0000000'

Test #3:

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

input:

5 4 1 4
8 8 8 8 100
1 2
2 3
3 4
4 5

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

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

input:

2 1 1 2
0 100000
1 2

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #5:

score: 0
Accepted
time: 166ms
memory: 15564kb

input:

632 199396 167 549
22513 93521 41403 35441 97617 53210 62622 4751 81863 14470 2994 93092 40432 30872 34423 36577 92540 92961 4110 14691 83321 10680 89112 80890 31108 24492 8973 42636 33792 27400 82361 85003 68940 31221 48625 276 52755 6649 34381 54399 6063 22628 17715 54052 58175 86609 82622 29917 9...

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #6:

score: 0
Accepted
time: 173ms
memory: 14852kb

input:

600 179700 396 574
83219 94660 9266 1939 32637 7117 33396 76947 42614 41001 87026 60210 25868 36044 35276 6147 36198 25195 50981 68230 32619 62563 28509 46643 43304 36195 99724 30903 77230 57923 36939 81397 17374 90947 48623 38120 48914 96481 98146 31707 9427 58735 82986 31328 94507 69081 51908 4188...

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #7:

score: 0
Accepted
time: 157ms
memory: 17140kb

input:

100000 200000 66364 98254
48399 8344 35365 18555 95271 13113 75220 25062 73969 71647 58212 68205 36310 45496 6965 59960 71592 81323 44341 95796 61521 63298 77830 16145 73103 83477 85246 53680 67289 68475 64978 43576 18969 28023 22848 55164 31276 12825 70999 49142 77203 40134 88148 59337 2357 70519 8...

output:

1019365473.000000

result:

ok found '1019365473.0000000', expected '1019365473.0000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 119ms
memory: 21204kb

input:

100000 200000 21412 38673
24050 75090 3692 20770 26840 57646 61096 3013 66291 73437 83126 67768 92979 69169 9389 70447 17151 74737 33407 3128 78504 52736 45853 27090 64395 24808 83577 24168 38576 37445 71022 40066 34908 90579 58370 31436 69812 39811 83370 50254 6518 72740 79316 67247 22759 65630 564...

output:

0.000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #9:

score: 0
Accepted
time: 165ms
memory: 21144kb

input:

100000 200000 75283 45047
38593 5224 81049 28255 11324 43744 51172 60916 67783 62336 96782 50029 48743 18780 32756 4774 32484 95733 17336 38046 98145 49655 68352 58308 21594 64540 11719 57827 30130 70076 95133 29886 93864 22677 28498 60413 44567 78935 64952 88954 85786 34019 75159 69192 15108 54645 ...

output:

6010044.500000

result:

ok found '6010044.5000000', expected '6010044.5000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 150ms
memory: 17088kb

input:

100000 200000 50293 63302
78731 76313 68601 46867 82806 57914 88495 43602 96202 44956 6593 96560 38650 61918 69911 48730 38668 8874 44449 25084 68496 18095 74789 52252 36631 68127 37908 63134 61923 68030 83186 81174 68083 78584 33622 74426 34099 32484 80162 10371 55894 65989 6374 76587 87442 50870 3...

output:

1926329544.000000

result:

ok found '1926329544.0000000', expected '1926329544.0000000', error '0.0000000'

Test #11:

score: -100
Wrong Answer
time: 142ms
memory: 20740kb

input:

100000 200000 81105 2350
9856 14867 98102 45742 76449 20173 90566 85519 8273 40573 98784 21094 38040 75579 21248 37555 32846 95358 92476 76093 99209 81806 76912 80248 93022 87883 85938 20897 20561 19811 59752 42986 36831 82149 73443 66562 96573 52522 68268 28832 46601 39663 61155 69950 13823 36697 9...

output:

2597874388.000000

result:

wrong answer 1st numbers differ - expected: '1746699958.0000000', found: '2597874388.0000000', error = '0.4873043'