QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#387583 | #3733. 地铁 | ucup-team1251 | WA | 45ms | 39232kb | C++17 | 1.4kb | 2024-04-12 17:02:15 | 2024-04-12 17:02:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
typedef pair<int, int> PII;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
struct node {
int x, c, t;
};
vector<node> e[N];
int dist[N];
bool st[N];
int cc[N];
void dijkstra() {
priority_queue<PII, vector<PII>, greater<PII> > q;
dist[1] = 0;
q.push({dist[1], 1});
while (q.size()) {
int ver = q.top().second;
q.pop();
if (st[ver]) continue;
st[ver] = 1;
for (auto &[j, c, t] : e[ver]) {
if (ver == 1) {
cc[1] = c;
}
if (dist[j] > dist[ver] + t + abs(cc[ver] - c)) {
dist[j] = dist[ver] + t + abs(cc[ver] - c);
cc[j] = c;
q.push({dist[j], j});
}
}
}
}
void solve() {
int n, m;
while (cin >> n >> m) {
for (int i = 1; i <= n; i++) {
e[i].clear();
dist[i] = 1e18;
st[i] = 0;
}
for (int i = 0; i < m; i++) {
int a, b, c, t;
cin >> a >> b >> c >> t;
e[a].push_back({b, c, t});
e[b].push_back({a, c, t});
}
dijkstra();
cout << dist[n] << '\n';
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tma = 15;
int _;
_ = 1;
// cin >> _;
while (_--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 31188kb
input:
2 1 1 2 1 1
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 33332kb
input:
500 2000 349 317 56 150 305 367 11 203 170 304 66 391 102 145 98 371 373 33 56 299 453 85 59 367 412 355 24 403 238 301 61 473 338 212 2 265 481 110 21 184 96 374 92 492 359 321 89 164 245 243 11 194 365 63 11 473 284 314 72 196 436 321 38 275 295 128 27 358 145 475 20 415 284 12 64 100 296 247 87 3...
output:
807
result:
ok 1 number(s): "807"
Test #3:
score: 0
Accepted
time: 0ms
memory: 30664kb
input:
500 2000 314 225 5 218 274 341 26 408 485 58 85 346 163 315 44 470 407 138 65 452 445 360 24 381 369 172 70 110 236 44 67 255 326 460 65 113 304 305 77 185 265 130 26 275 422 49 16 222 251 306 14 74 48 250 31 438 158 300 42 434 415 486 88 325 353 232 90 459 24 402 7 129 440 352 43 92 462 138 65 267 ...
output:
302
result:
ok 1 number(s): "302"
Test #4:
score: 0
Accepted
time: 0ms
memory: 33368kb
input:
500 2000 172 456 43 391 276 130 54 165 381 460 29 400 470 97 94 338 246 192 1 403 355 208 73 399 254 116 29 124 362 397 26 77 424 157 23 5 471 424 77 196 149 134 11 468 86 193 40 162 50 440 51 42 81 231 50 224 372 465 43 307 58 452 16 76 97 244 78 255 235 256 67 321 31 234 47 227 421 180 15 137 72 4...
output:
529
result:
ok 1 number(s): "529"
Test #5:
score: 0
Accepted
time: 4ms
memory: 30108kb
input:
500 2000 152 441 18 475 20 488 64 424 452 319 45 1 468 368 87 476 394 268 86 473 98 98 96 63 90 291 74 375 312 328 87 95 151 464 26 206 351 5 93 86 2 287 64 479 363 180 75 391 50 446 76 206 492 351 12 91 75 287 100 347 145 402 51 441 35 347 69 26 104 493 2 150 201 122 8 380 41 41 78 206 388 155 94 4...
output:
490
result:
ok 1 number(s): "490"
Test #6:
score: 0
Accepted
time: 0ms
memory: 31556kb
input:
500 2000 58 58 29 475 45 198 43 122 111 477 37 193 57 169 44 247 428 353 26 86 364 498 74 498 416 40 19 119 259 377 18 327 91 200 31 335 165 145 57 109 461 461 85 103 282 452 24 227 479 474 81 11 56 491 58 57 442 442 88 178 349 284 49 135 297 447 4 297 133 328 92 198 52 138 46 424 239 383 19 233 117...
output:
493
result:
ok 1 number(s): "493"
Test #7:
score: -100
Wrong Answer
time: 45ms
memory: 39232kb
input:
50000 100000 40192 23804 17447 9621 1570 10683 11150 35699 7479 163 2185 43718 8196 38715 44977 16615 3564 43385 14545 44583 1602 35591 46813 20550 24281 2679 175 18065 12482 44950 24866 12796 4068 6517 4019 7841 18247 28028 39909 30312 23301 445 30724 49992 152 3284 797 4718 28616 32003 14685 30844...
output:
90205348
result:
wrong answer 1st numbers differ - expected: '88978275', found: '90205348'