QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138447 | #4357. School Road | Antekb# | 35 | 305ms | 56900kb | C++14 | 2.3kb | 2023-08-11 18:40:04 | 2024-07-04 01:37:02 |
Judging History
answer
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=2e5+5;
vii E[N];
ll dist[N], dist2[N];
set<int> edg[N],redg[N];
set<int> zle;
int n;
void update(int v){
if(v>1 && v!=n && edg[v].size()==1 && redg[v].size()==1)zle.insert(v);
}
int main(){
int m;
cin>>n>>m;
for(int i=0; i<m; i++){
int u, v, w;
cin>>u>>v>>w;
E[u].eb(v, w);
E[v].eb(u, w);
}
for(int i=1; i<=n; i++){
dist[i]=dist2[i]=1e18;
}
dist[1]=0;
dist2[n]=0;
priority_queue<pair<ll, int>> Q;
for(int i=1; i<=n; i++){
Q.push(mp(-dist[i], i));
}
while(Q.size()){
ll d=-Q.top().st;
int v=Q.top().nd;
Q.pop();
if(dist[v]!=d)continue;
for(pii u:E[v]){
if(dist[u.st]>d+u.nd){
dist[u.st]=d+u.nd;
Q.push(mp(-dist[u.st], u.st));
}
}
}
for(int i=1; i<=n; i++){
Q.push(mp(-dist2[i], i));
}
while(Q.size()){
ll d=-Q.top().st;
int v=Q.top().nd;
//cerr<<d<<" "<<v<<"\n";
Q.pop();
if(dist2[v]!=d)continue;
for(pii u:E[v]){
if(dist2[u.st]>d+u.nd){
dist2[u.st]=d+u.nd;
Q.push(mp(-dist2[u.st], u.st));
}
}
}
for(int i=1; i<=n; i++){
//cerr<<i<<" "<<dist[i]<<" "<<dist2[i]<<"\n";
}
ll L=dist[n];
for(int v=1; v<=n; v++){
if(dist[v]+dist2[v]!=L){
cerr<<v<<"\n";
cerr<<dist[v]<<" "<<dist2[v]<<"\n";
cout<<1;
return 0;
}
for(pii u:E[v]){
if(dist[u.st]>dist[v] && dist[u.st]!=dist[v]+u.nd){
cerr<<v<<" "<<u.st<<" "<<u.nd<<"\n";
cout<<1;
return 0;
}
else if(dist[u.st]>dist[v]){
edg[v].insert(u.st);
redg[u.st].insert(v);
}
}
}
for(int i=1; i<=n; i++){
update(i);
//cerr<<edg[i].size()<<" "<<redg[i].size()<<"\n";
}
while(zle.size()){
int v=*zle.begin();
zle.erase(v);
int a=*redg[v].begin(), b=*edg[v].begin();
//cerr<<v<<" "<<a<<" "<<b<<"\n";
edg[a].erase(v);
redg[b].erase(v);
edg[a].insert(b);
redg[b].insert(a);
update(a);
update(b);
}
if(*(edg[1].begin())!=n){
cout<<1;
}
else cout<<0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 30212kb
input:
14 40 8 12 570429827 6 10 592780730 13 14 299807355 4 10 729771483 4 10 729771483 6 9 746405411 2 3 696576351 12 14 192640790 4 13 284900209 1 2 857968292 12 14 192640790 8 12 570429827 6 10 592780730 6 9 746405411 9 11 329648726 4 13 284900209 2 3 696576351 4 10 729771483 5 11 101819611 3 7 1824073...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 15
Accepted
time: 3ms
memory: 30156kb
input:
18 40 3 10 26965732 5 15 67047331 3 17 42474964 13 15 129212204 9 18 142540287 2 14 27157962 5 15 67047331 5 15 67047331 5 15 67047331 4 16 212978971 6 12 51548223 4 18 192438222 13 16 60052417 16 17 162364835 6 17 55527270 9 11 58810843 3 7 95393586 13 15 129212204 2 17 67824762 5 15 67047331 15 16...
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Wrong Answer
time: 5ms
memory: 30244kb
input:
18 51 5 16 489370441 7 8 674383722 8 11 602435525 1 10 856666364 13 18 650829027 11 14 198398173 3 4 613940394 15 17 123758204 8 11 602435525 3 6 567757815 13 18 650829027 14 15 236674174 3 4 613940394 5 18 956980171 6 16 887883755 3 6 567757815 6 16 887883755 5 18 956980171 4 10 339471731 11 14 198...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #3:
score: 0
Wrong Answer
Test #18:
score: 23
Accepted
time: 209ms
memory: 48388kb
input:
100000 99999 42115 93495 19881095 21969 68351 161710 7405 86343 27129 37307 45676 320013 30388 71545 117761 22026 68957 65332 77949 81644 2281387 24865 95079 341488 9849 98496 2548159 53911 79572 4962105 24880 62622 1678564 15943 22168 1524688 67424 78323 2450655 32175 74893 1908332 35640 39305 1043...
output:
0
result:
ok single line: '0'
Test #19:
score: 23
Accepted
time: 203ms
memory: 48476kb
input:
100000 100013 19959 56142 776045 6894 37840 718015 11415 73383 1519031 35732 78712 566052 78739 96739 584053 24958 28098 854234 27498 62413 1735265 27341 91341 11692771 46008 96501 299421 14384 78871 1903953 15562 33609 158393 5270 76189 69630274 38130 51331 187183 61589 75145 81438587 45138 86388 5...
output:
0
result:
ok single line: '0'
Test #20:
score: 0
Wrong Answer
time: 128ms
memory: 34976kb
input:
100000 100013 30467 74396 2840367 12869 90814 1569862 18883 60521 211271 95973 98805 3444504 52606 61422 697591 49637 61784 1034159 21957 33982 3827036 10128 68617 444124 20731 81447 5807317 15570 35763 123607 22128 33827 59368 34479 41370 15053204 52297 55748 435155 22820 56102 66369 19316 92816 76...
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'
Subtask #4:
score: 35
Accepted
Test #57:
score: 35
Accepted
time: 0ms
memory: 30104kb
input:
18 400 11 18 145314505 1 18 242896789 1 18 242896789 5 13 31030812 13 18 93451080 1 18 242896789 1 7 123378068 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 18 242896789 1 3 42183985 1 18 242896789 13 18 93451080 1 18 242896789 13 18 93451080 1 18 242896789 1 18 242896...
output:
0
result:
ok single line: '0'
Test #58:
score: 35
Accepted
time: 92ms
memory: 33312kb
input:
18 200000 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 758096510 1 18 ...
output:
0
result:
ok single line: '0'
Test #59:
score: 35
Accepted
time: 96ms
memory: 33072kb
input:
18 200000 1 16 142470606 1 16 142470606 1 16 142470606 1 16 142470606 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 16 142470606 1 16 142470606 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 18 403405575 1 16 142470606 1 18 403405575 1 16 142470606 16 18...
output:
1
result:
ok single line: '1'
Test #60:
score: 35
Accepted
time: 97ms
memory: 33676kb
input:
18 200000 4 9 299686894 3 5 299686894 7 8 299686894 1 16 299686894 3 17 299686894 6 9 299686894 12 15 299686894 4 14 299686894 2 5 299686894 15 16 299686894 4 9 299686894 5 17 299686894 3 5 299686894 1 12 299686894 9 13 299686894 6 16 299686894 3 4 299686894 12 17 299686894 6 11 299686894 6 16 29968...
output:
1
result:
ok single line: '1'
Test #61:
score: 35
Accepted
time: 125ms
memory: 34956kb
input:
100000 100013 58740 94702 183108 37735 80452 620754 37294 78858 10966952 37514 85983 339130 12698 97268 45544120 69733 89994 8521209 75252 91512 12575878 277 80124 76073 17061 55209 7457230 36796 62730 7849522 45347 80689 1830312 35585 68837 368255 36459 46047 4254924 70264 73565 812524 37921 93786 ...
output:
1
result:
ok single line: '1'
Test #62:
score: 35
Accepted
time: 305ms
memory: 53980kb
input:
100000 200000 6389 94276 543986 25881 32460 603154 20645 64539 4139 27806 62727 1392853 14364 61295 175740 65909 76384 35860 40746 88474 348638 35372 49809 127422 43618 50453 115413 28758 97249 167174 49253 61224 39406485 3792 20026 6179775 50603 93717 112986 34416 93394 447809 28574 46252 400986 13...
output:
0
result:
ok single line: '0'
Test #63:
score: 35
Accepted
time: 203ms
memory: 37672kb
input:
100000 200000 24725 29360 197211 44680 71239 730893 85529 87832 449578 39513 51620 1031826 77875 89486 16491 11369 29754 100365 69956 76984 719102 13087 92813 38507 49442 61243 3201165 47378 81971 85463 43814 50975 320182 9202 74616 319851 14605 71864 3312698 55212 78262 990377 27248 91330 3869294 2...
output:
1
result:
ok single line: '1'
Test #64:
score: 35
Accepted
time: 106ms
memory: 35492kb
input:
632 200000 304 518 193336272 116 330 193336272 388 561 193336272 42 444 193336272 73 210 193336272 233 234 193336272 387 415 193336272 30 522 193336272 349 566 193336272 152 299 193336272 281 284 193336272 328 460 193336272 425 623 193336272 238 555 193336272 77 205 193336272 257 483 193336272 400 4...
output:
1
result:
ok single line: '1'
Test #65:
score: 35
Accepted
time: 0ms
memory: 30148kb
input:
18 40 5 15 50975681 1 2 74937538 4 10 189052037 1 10 339538497 1 6 196128065 17 18 87791006 17 18 87791006 10 15 22357365 6 10 143410432 1 12 90560040 7 12 37957752 4 18 152090080 4 10 189052037 7 8 22323879 10 11 84245069 1 18 680680614 1 14 210991479 1 18 680680614 7 10 211020705 3 14 78015728 7 8...
output:
0
result:
ok single line: '0'
Test #66:
score: 35
Accepted
time: 4ms
memory: 30328kb
input:
14 40 4 14 201959209 1 7 643527151 13 14 404522008 1 6 302820793 13 14 404522008 2 14 638562403 3 5 296099363 1 12 347078002 7 14 614904306 1 5 109066023 1 3 405165386 13 14 404522008 1 8 282439697 13 14 404522008 10 13 301981140 3 5 296099363 1 3 405165386 3 6 102344593 3 5 296099363 1 7 643527151 ...
output:
0
result:
ok single line: '0'
Test #67:
score: 35
Accepted
time: 4ms
memory: 30044kb
input:
10 40 4 10 155190875 5 6 84217558 1 4 79668122 1 10 234858997 5 10 89763187 1 8 28014408 2 10 104545101 2 9 71819408 1 10 234858997 1 4 79668122 1 10 234858997 1 4 79668122 4 10 155190875 1 10 234858997 1 10 234858997 1 4 79668122 1 10 234858997 7 10 102844530 2 9 71819408 5 6 84217558 4 10 15519087...
output:
0
result:
ok single line: '0'
Test #68:
score: 35
Accepted
time: 0ms
memory: 30080kb
input:
6 40 1 5 127753864 2 6 165487825 1 6 237608934 1 2 72121109 3 5 49940392 1 6 237608934 1 6 237608934 1 6 237608934 1 6 237608934 1 6 237608934 5 6 109855070 1 6 237608934 3 6 59914678 5 6 109855070 1 5 127753864 1 5 127753864 1 5 127753864 1 5 127753864 1 6 237608934 1 5 127753864 1 5 127753864 1 6 ...
output:
0
result:
ok single line: '0'
Test #69:
score: 35
Accepted
time: 2ms
memory: 30256kb
input:
9 40 3 7 820765894 1 3 820765894 4 8 820765894 1 6 820765894 1 8 820765894 2 5 820765894 5 7 820765894 2 3 820765894 7 9 820765894 4 5 820765894 7 8 820765894 5 6 820765894 1 5 820765894 1 6 820765894 2 7 820765894 2 6 820765894 5 8 820765894 3 5 820765894 3 8 820765894 5 9 820765894 2 4 820765894 3...
output:
1
result:
ok single line: '1'
Test #70:
score: 35
Accepted
time: 4ms
memory: 30284kb
input:
27 40 3 11 21554227 2 23 43259751 1 22 14720102 12 27 59560397 1 6 53293849 2 23 43259751 9 16 8245874 11 27 273216446 1 6 53293849 8 24 17981555 3 21 11775055 13 19 45763922 4 11 19082667 14 19 46767692 2 7 64440055 13 21 45734158 5 7 57603827 7 18 8475649 1 17 72776469 10 11 14098552 23 25 3479727...
output:
0
result:
ok single line: '0'
Test #71:
score: 35
Accepted
time: 3ms
memory: 30280kb
input:
2 1 1 2 302129880
output:
0
result:
ok single line: '0'
Test #72:
score: 35
Accepted
time: 0ms
memory: 30088kb
input:
2 2 1 2 303710711 1 2 303710711
output:
0
result:
ok single line: '0'
Test #73:
score: 35
Accepted
time: 0ms
memory: 30200kb
input:
3 4 2 3 241174708 1 2 275099430 1 3 516274138 1 3 516274138
output:
0
result:
ok single line: '0'
Test #74:
score: 35
Accepted
time: 8ms
memory: 30064kb
input:
4 5 2 4 221389228 3 4 318254756 1 3 235436705 1 3 235436705 1 2 332302233
output:
0
result:
ok single line: '0'
Test #75:
score: 35
Accepted
time: 8ms
memory: 30012kb
input:
4 6 3 4 75669978 2 3 67113642 1 2 58298560 1 4 201082180 1 4 201082180 1 4 201082180
output:
0
result:
ok single line: '0'
Test #76:
score: 35
Accepted
time: 4ms
memory: 30084kb
input:
5 6 1 4 77220535 1 2 75417384 2 5 168870904 3 5 126891262 1 5 244288288 3 4 40176491
output:
0
result:
ok single line: '0'
Test #77:
score: 35
Accepted
time: 4ms
memory: 30272kb
input:
5 7 3 4 335644701 1 3 243730807 3 5 628570052 2 5 155669565 3 5 628570052 2 4 137255786 1 5 872300859
output:
0
result:
ok single line: '0'
Test #78:
score: 35
Accepted
time: 2ms
memory: 30020kb
input:
18 31 8 17 4629967 1 9 3718690 2 6 1042805 5 8 4543223 13 17 5964666 11 12 5524351 4 9 2912286 2 3 2120380 7 16 2854314 5 18 5891742 10 15 606691 4 7 1841464 6 10 790038 14 15 831933 5 18 5891742 5 12 7354030 2 5 18399015 4 7 1841464 5 12 7354030 5 18 5891742 7 14 841993 11 12 5524351 13 17 5964666 ...
output:
0
result:
ok single line: '0'
Test #79:
score: 35
Accepted
time: 4ms
memory: 30148kb
input:
2 2 1 2 1 1 2 2
output:
1
result:
ok single line: '1'
Test #80:
score: 35
Accepted
time: 2ms
memory: 30156kb
input:
18 34 8 12 6214231 4 6 577493710 10 14 129756694 6 17 6010149 2 6 742883201 6 18 60331329 3 6 62377980 2 16 9315916 3 17 56367832 14 15 7640994 9 10 10361790 6 8 206618382 6 7 601558969 8 15 124578764 4 9 98537086 6 14 338838140 6 15 331197146 1 16 57246820 12 13 71476592 3 11 736163 6 17 6010148 6 ...
output:
1
result:
ok single line: '1'
Test #81:
score: 35
Accepted
time: 3ms
memory: 30032kb
input:
18 34 8 12 6214231 4 6 577493710 10 14 129756694 6 17 6010149 2 6 742883201 1 6 60331329 3 6 62377980 2 16 9315916 3 17 56367832 14 15 7640994 9 10 10361790 6 8 206618382 6 7 601558969 8 15 124578764 4 9 98537086 6 14 338838140 6 15 331197146 16 18 57246820 12 13 71476592 3 11 736163 6 17 6010148 6 ...
output:
1
result:
ok single line: '1'
Test #82:
score: 35
Accepted
time: 0ms
memory: 30248kb
input:
18 99 5 13 1000000000 14 17 1000000000 2 6 742883201 7 13 1000000000 12 15 1000000000 3 8 1000000000 5 12 1000000000 10 13 1000000000 11 17 1000000000 6 7 601558969 12 13 1000000000 5 9 1000000000 13 14 1000000000 1 18 869777266 1 6 809445937 4 15 1000000000 3 15 1000000000 11 13 1000000000 7 9 1000...
output:
1
result:
ok single line: '1'
Test #83:
score: 35
Accepted
time: 0ms
memory: 30080kb
input:
18 99 5 13 1000000000 14 17 1000000000 2 6 742883201 7 13 1000000000 12 15 1000000000 3 8 1000000000 5 12 1000000000 10 13 1000000000 11 17 1000000000 6 7 601558969 12 13 1000000000 5 9 1000000000 13 14 1000000000 1 18 869777266 6 18 809445937 4 15 1000000000 3 15 1000000000 11 13 1000000000 7 9 100...
output:
1
result:
ok single line: '1'
Test #84:
score: 35
Accepted
time: 265ms
memory: 56900kb
input:
100000 200000 2490 93587 1507 72073 83033 348 51946 98099 455645608 19582 57583 2495 28771 62316 33854 21828 39759 794751371 27016 62418 753537084 45984 54306 706685061 39738 78391 293736822 32568 58812 199327587 37435 43715 9202 19211 80255 6058 13351 28338 923320339 35275 83476 12491 138 76683 117...
output:
1
result:
ok single line: '1'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%