QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#875532 | #8804. Treasure Hunt | Mispertion# | 5 | 4ms | 8276kb | C++23 | 2.0kb | 2025-01-29 22:37:44 | 2025-01-29 22:37:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define int ll
using ld = long double;
using pii = pair<int, int>;
#define S second
#define F first
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define mispertion ios_base::sync_with_stdio(0),cin.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
const ld PI = 3.1415926535;
const ld eps = 1e-9;
const int N = 5e5 + 2;
const int M = 1.5e6 + 13;
ll mod = 1e9+7;
const int infi = 1e18;
const ll infl = 1e16;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod; }
int sum(int a, int b) {
if(a + b >= mod)
return a + b - mod;
if(a + b < 0)
return a + b + mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0) return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % (mod);
} else {
ll b = binpow(a, n / 2);
return b * b % (mod);
}
}
int n, m, a[N], d[N];
vector<pii> g[N];
inline void solve() {
cin >> n >> m;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= m; i++){
int u, v, w;
cin >> u >> v >> w;
g[u].push_back({v, w});
g[v].push_back({u, w});
}
for(int i = 1; i <= n; i++)
d[i] = -a[i];
set<pii> st;
for(int i = 1; i <= n; i++)
st.insert({d[i], i});
while(!st.empty()){
int v = st.begin()->S;
st.erase(st.begin());
for(auto u : g[v]){
if(d[u.F] > d[v] + u.S){
st.erase({d[u.F], u.F});
d[u.F] = d[v] + u.S;
st.insert({d[u.F], u.F});
}
}
}
for(int i= 1; i <= n; i++)
cout << -d[i] << '\n';
}
signed main() {
mispertion;
int t = 1;
//cin >> t;
for(int i = 1; i <= t; i ++){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 2ms
memory: 8220kb
input:
3000 3000 735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 884526087 620...
output:
735362183 713607491 748793363 638030501 876390252 836223236 824664802 606295597 80970666 766403495 110657364 506742426 693285991 945447633 641155308 365329924 969038868 372617561 823982498 896717651 845481436 239161696 404588333 709818617 665021093 770870148 892408756 925221803 884526087 620849020 4...
result:
ok 3000 lines
Test #2:
score: 5
Accepted
time: 1ms
memory: 8276kb
input:
3000 3000 972166434 659979142 344453258 395615030 984580008 713698299 329234177 681387709 35749436 498013633 220323044 838758786 923230288 22789609 51100137 72217062 885300626 948320992 132324930 312694252 176178575 402178209 741891771 522780632 408427186 105944768 787335363 218283387 849372992 5957...
output:
972166434 659979142 344453258 395615030 984580008 713698299 530975034 681387709 35749436 498013633 751022649 838758786 923230288 726365962 649403959 463998322 885300626 948320992 524349273 312694252 210337883 402178209 741891771 522780632 617934022 285654027 787335363 319154448 849372992 595755284 5...
result:
ok 3000 lines
Test #3:
score: 5
Accepted
time: 1ms
memory: 8136kb
input:
2000 3000 89876544 891255474 713979450 673065048 959236666 891228417 823405883 753035428 482478944 549110878 713746013 765809948 625394351 540810211 138742853 783651116 702745446 409263449 264555022 816159076 52123129 217641066 839925219 574406717 62302724 439732057 489026494 910128266 443257992 284...
output:
287183883 891255474 713979450 673065048 959236666 891228417 823405883 753035428 482478944 549110878 713746013 765809948 969087262 679664735 138742853 783651116 702745446 409263449 264555022 816159076 193516777 662862609 839925219 591556952 817074001 439732057 489026494 910128266 443257992 495558697 ...
result:
ok 2000 lines
Test #4:
score: 5
Accepted
time: 1ms
memory: 8148kb
input:
2500 3000 0 1000000000 1000000000 0 1000000000 0 0 0 1000000000 0 0 1000000000 1000000000 1000000000 1000000000 0 1000000000 1000000000 0 1000000000 0 1000000000 1000000000 1000000000 0 0 0 0 0 1000000000 1000000000 0 1000000000 1000000000 0 0 1000000000 1000000000 0 0 1000000000 1000000000 0 0 1000...
output:
942200830 1000000000 1000000000 981175572 1000000000 757267853 899967379 942714211 1000000000 968845504 983558248 1000000000 1000000000 1000000000 1000000000 909088479 1000000000 1000000000 993668068 1000000000 977419757 1000000000 1000000000 1000000000 922529645 914574859 834950123 949162003 984312...
result:
ok 2500 lines
Test #5:
score: 5
Accepted
time: 2ms
memory: 7916kb
input:
1 0 321300751
output:
321300751
result:
ok single line: '321300751'
Test #6:
score: 5
Accepted
time: 0ms
memory: 7792kb
input:
2 1 853072294 184328520 2 1 851046910
output:
853072294 184328520
result:
ok 2 lines
Test #7:
score: 5
Accepted
time: 0ms
memory: 7916kb
input:
2 1 675815113 47008633 2 1 6
output:
675815113 675815107
result:
ok 2 lines
Test #8:
score: 5
Accepted
time: 0ms
memory: 8144kb
input:
2500 3000 379463792 434038125 450232165 663119022 929634691 447981861 727168756 29268678 101836976 59313172 163410609 911233882 271997950 792478625 498842948 39299739 765233121 649993425 224429598 273261981 60031711 640196758 459418686 462647695 127051736 729475488 214312090 325910804 917313496 2862...
output:
547193069 440194410 450232165 663119022 929634691 447981861 727168756 271856431 248749749 594252697 503284922 911233882 428729760 792478625 730703326 772883484 765233121 649993425 811011354 675845739 60031711 640196758 459418686 462647695 151284835 729475488 473808304 325910804 917313496 534753256 8...
result:
ok 2500 lines
Test #9:
score: 5
Accepted
time: 4ms
memory: 8148kb
input:
2900 3000 907239320 296718238 746129428 645601748 535695129 920479272 516307753 100916397 548566484 110410418 656833578 206881262 269129306 679095446 176420246 750733793 582677942 110935882 356659690 850355733 641008975 792096104 926048354 809241072 780927275 63262777 916003222 649159463 879794716 2...
output:
938028985 922240406 956341467 941286153 954230202 928107144 934466597 973400247 956549385 969018793 961798979 983602183 955618729 981158657 970897143 958170867 961500391 939199249 973819296 945862595 958847551 968684454 964831858 991882039 930429549 953277068 970182637 981209637 957331204 959350195 ...
result:
ok 2900 lines
Test #10:
score: 5
Accepted
time: 4ms
memory: 8144kb
input:
2999 3000 439010862 3645191 79776002 771782497 348917593 166550553 411698322 885973241 798312546 547053265 61466548 467196975 867669823 387841203 996430494 321464341 203972407 686639313 370034831 192703406 971706114 377867262 968384499 327235794 524333368 398337398 105897120 942221048 771012693 2449...
output:
838630177 766463608 771992302 771782497 736709507 768325886 791363796 885973241 987577202 898829426 841532524 934046211 867669823 802901352 996430494 786451689 869847652 820256860 810593013 809367366 971706114 993070845 968384499 857619845 775779138 890414804 858374280 942221048 881426821 591166009 ...
result:
ok 2999 lines
Test #11:
score: 5
Accepted
time: 1ms
memory: 8124kb
input:
78 3000 261753681 571358012 80705973 49232514 323574252 344080671 569433539 252588251 950074762 303183218 964954934 689215428 569833886 274458024 42604012 327865686 947788301 147581770 502264923 769797158 184087157 824733900 66417946 42425390 473176198 732124687 512620959 634065926 733493913 2288113...
output:
957872045 941317803 923248410 928079951 919143835 925045585 955227739 919862587 950074762 912140358 964954934 910667899 961985075 947768113 934453336 956108913 947788301 951023126 928002673 926483044 934246878 952546437 954247154 937144277 909846779 923686351 965431007 920535934 952567447 920846824 ...
result:
ok 78 lines
Test #12:
score: 5
Accepted
time: 0ms
memory: 8228kb
input:
2251 3000 1000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
1000000000 999999999 999999000 999999998 999999997 999998998 999999996 999999995 999998996 999999994 999999993 999998994 999999992 999999991 999998992 999999990 999999989 999998990 999999988 999999987 999998988 999999986 999999985 999998986 999999984 999999983 999998984 999999982 999999981 999998982...
result:
ok 2251 lines
Test #13:
score: 5
Accepted
time: 0ms
memory: 7920kb
input:
59 87 1000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 2 3 1 1 3 536870912 3 4 1 4 5 1 3 5 268435456 5 6 1 6 7 1 5 7 134217728 7 8 1 8 9 1 7 9 67108864 9 10 1 10 11 1 9 11 33554432 11 12 1 12 13 1 11 13 16777216 13 1...
output:
1000000000 999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 999999990 999999989 999999988 999999987 999999986 999999985 999999984 999999983 999999982 999999981 999999980 999999979 999999978 999999977 999999976 999999975 999999974 999999973 999999972 999999971...
result:
ok 59 lines
Subtask #2:
score: 0
Runtime Error
Test #14:
score: 0
Runtime Error
input:
1000000 1000000 735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 8845260...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #30:
score: 0
Runtime Error
input:
1000000 999999 735362183 321648408 84435611 638030501 876390252 836223236 65247387 527734646 80970666 766403495 110657364 283475781 693285991 945447633 641155308 132890294 969038868 372617561 823982498 896717651 845481436 111374342 404588333 709818617 665021093 770870148 892408756 925221803 88452608...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%