QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135667 | #3871. Voting Cities | Wawi# | 0 | 88ms | 4428kb | C++20 | 1.5kb | 2023-08-05 21:05:29 | 2024-07-04 01:17:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct cp{
bool operator()(pair<int,int> a, pair<int,int> b) const {
return a.first < b.first;
}
};
void solve(){
int n,m,k; cin >> n >> m >> k;
vector<int> go(k);
for(int i=0; i < k;i++) cin >> go[i];
vector<vector<pair<int,int>>> arr(n+1);
for(int i=0; i < m;i++){
int l,r,c; cin >> l >> r >> c;
arr[l].push_back({r,c});
arr[r].push_back({l,c});
}
int q; cin >> q;
while(q--){
int s; cin >> s;
int temp; cin >> temp >> temp >> temp >> temp >> temp;
multiset<pair<int,int>,cp> st;
for(auto c:arr[s]){
st.insert({c.second,c.first});
}
vector<bool> found(n+1);
found[s]=true;
while(!st.empty()){
pair<int,int> c=*st.begin();
st.erase(st.begin());
if(found[c.second]) continue;
found[c.second]=true;
if(c.second==go[0]){
cout << c.first << endl;
break;
}
for(auto g:arr[c.second]){
if(found[g.first]) continue;
st.insert({c.first + g.second,g.first});
}
}
if(!found[go[0]]) cout << -1 << endl;
}
}
int main() {
ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
int t=1;
// cin >> t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4428kb
input:
5000 10000 1 4683 0 715 579327370 0 954 664830350 0 2453 244225980 0 2918 399241150 0 3929 982683290 1 4944 723915200 2 3725 390369490 3 1370 230814450 3 3348 750421430 3 3408 503334040 4 252 852709300 4 989 474431070 4 1013 466847840 4 4956 152207550 5 4162 271201150 6 3335 991911830 6 3596 4382854...
output:
46529694
result:
wrong answer 1st lines differ - expected: '7570531610', found: '46529694'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 68ms
memory: 4276kb
input:
5000 10000 1 939 0 1074 697931020 0 4334 347738890 1 2400 681303040 2 1685 896587820 2 2368 928896100 2 3133 12276450 2 3258 765661210 4 3606 993201320 5 1081 613705100 5 2339 700470170 5 2625 209307440 5 2832 129029550 7 1517 251821020 7 1751 713428320 7 2308 951691550 7 3980 498317440 7 4014 78197...
output:
232148044 177757584 341384524 700381614 228184064 311789354 59561254 233137484 -604593876 -585954026 -812455036 -1192821166 -16487406 -131838706 -403096446 -480107686 -275415616 -572813186 -564710956 513595484 1145003664 -306221476 -341586576 355179994 156841944 -894852306 -307636896 -224075496 -126...
result:
wrong answer 1st lines differ - expected: '5627552460', found: '232148044'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 88ms
memory: 4248kb
input:
5000 10000 2000 366 1016 3277 5 3742 3640 2511 1725 2168 2349 1037 4972 2930 4374 3504 1098 3439 3970 1952 3474 2664 2097 1751 3679 3155 3266 2070 2016 338 1273 2648 4398 3694 2045 3524 1027 839 1898 1795 1192 2975 1756 4707 1548 4984 1891 2364 123 3181 1096 2970 3264 1628 1295 4852 829 4940 2251 37...
output:
-14909566 69874644 336372844 82432604 554444184 -1 135657934 333640474 -305080426 -668231816 596471334 -75524066 488403864 169676564 163335424 235772544 -434967676 633419624 192090574 267525004 -207027206 492985014 -63747326 620658664 -31306186 219524414 137288374 180650054 459923304 -244848326 5725...
result:
wrong answer 1st lines differ - expected: '0', found: '-14909566'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 4ms
memory: 4196kb
input:
5000 10000 1 4577 0 248 57534230 0 3020 827662530 0 3190 138424730 1 3154 752916230 4 1256 398736840 5 4116 833556610 5 4127 547494700 6 396 793865570 6 1661 388141660 7 4581 595148940 8 3768 724151300 9 1367 840320860 9 1656 391917460 10 3210 806346090 10 3356 767016610 10 3367 272248610 12 1145 72...
output:
1334070090
result:
wrong answer 1st lines differ - expected: '-1', found: '1334070090'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 39ms
memory: 4172kb
input:
5000 10000 200 1044 1225 1941 2497 4667 2566 3603 92 2261 1826 770 4780 127 4386 1948 2156 1504 4511 3119 4006 4473 389 3469 2670 3989 3092 55 670 4525 4965 1038 375 419 2599 4912 3665 4799 2997 4759 1660 1136 2308 1707 4249 3246 625 3378 52 734 4317 4958 3355 869 3361 2010 2300 2809 2635 2241 3441 ...
output:
-150102076 -69120646 -118820476 552739290 -82176956 830602074 -460742336 147349964 -429243216 -717894146 -215350536 -265031836 10139334 247794074 -46772226 64070874 -1197142566 674478314 -610637266 440774374 -552730006 -755308136 -357822856 459530464 -200639736 -809419446 997724500 -547927156 299924...
result:
wrong answer 1st lines differ - expected: '-1', found: '-150102076'
Subtask #7:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 6ms
memory: 3824kb
input:
100 1000 10 98 30 76 47 68 72 37 62 38 78 0 40 955510110 0 58 380472040 0 67 471726660 0 75 21910230 0 76 203779460 0 79 619337400 0 92 789108960 0 95 850838250 1 7 708430 1 8 800979960 1 24 529606990 1 25 822365030 1 40 803087030 1 75 339182160 1 79 841073850 1 86 249876300 1 92 93708160 2 6 653731...
output:
31965470 209610240 185569060 195521840 308957750 202425800 429545340 88618840 171272390 318552300 397267600 368574510 280751380 182231390 144559570 203385240 169708900 228626840 160888710 117847240 295497610 240318970 353475530 368899630 132545750 257274380 56486000 162075330 257324130 215848080 210...
result:
wrong answer 1st lines differ - expected: '410099610', found: '31965470'
Subtask #8:
score: 0
Skipped
Dependency #1:
0%