QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#953610#10023. Kangaroo On GraphjimmyywangTL 431ms68820kbC++231.6kb2025-03-27 21:35:232025-03-27 21:35:24

Judging History

This is the latest submission verdict.

  • [2025-03-27 21:35:24]
  • Judged
  • Verdict: TL
  • Time: 431ms
  • Memory: 68820kb
  • [2025-03-27 21:35:23]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define wt int tt=d;while(tt--)
#define py puts("Yes")
#define pn puts("No")
#define fe(i,e) for(int i=0;i<e.size();i++)
#define vi vector<ll>
inline ll rd() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d rd()
#define pb push_back
ll n,m;
struct edge{ll v,w,nx;}e[400010];
ll hd[200010],cnt;
void add(ll u,ll v,ll w){e[++cnt]=(edge){v,w,hd[u]};hd[u]=cnt;}
map<array<int,2>,bool>vis;
map<array<int,2>,ll>dis;
map<array<int,3>,bool>forb;
priority_queue<array<ll,3>,vector<array<ll,3>>,greater<array<ll,3>>>q;
ll res=0x3f3f3f3f3f3f3f3f;
int main(){
	n=d,m=d;
    f(i,1,m){
        ll u=d,v=d,w=d;
        add(u,v,w);
    }
    ll __=d;
    f(i,1,__){
        int a=d,b=d,c=d;
        forb[{a,b,c}]=1;
    }dis[{0,1}]=0;q.push({0,0,1});
    while(!q.empty()){
        auto qwq=q.top();q.pop();
        ll ds=qwq[0];int pre=qwq[1],u=qwq[2];
        if(vis[{pre,u}])continue;vis[{pre,u}]=1;
        // cout<<pre<<" "<<u<<" "<<ds<<endl;
        if(u==n)res=min(res,ds);
        for(int i=hd[u];i;i=e[i].nx){
            int v=e[i].v;ll w=e[i].w;
            if(pre<u&&u<v&&forb[{pre,u,v}])continue;
            if(dis.find({u,v})==dis.end()||dis[{u,v}]>ds+w){
                dis[{u,v}]=ds+w;
                // cout<<pre<<" "<<u<<" "<<v<<" "<<ds<<" "<<w<<endl;
                q.push({dis[{u,v}],u,v});
            }
        }
    }if(res==0x3f3f3f3f3f3f3f3f)puts("-1");
    else cout<<res;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5712kb

input:

4 4
1 3 2
1 2 3
2 4 3
3 4 3
1
1 3 4

output:

6

result:

ok answer is '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 5712kb

input:

7 8
1 3 5
1 2 2
3 4 1
2 4 1
4 5 6
4 6 2
5 7 1
6 7 1
2
3 4 5
2 4 6

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 0ms
memory: 5712kb

input:

4 3
1 2 3
2 3 4
3 4 1
1
1 2 3

output:

-1

result:

ok answer is '-1'

Test #4:

score: 0
Accepted
time: 245ms
memory: 54612kb

input:

150001 200000
27259 27261 590380540
62249 62251 781612972
142049 142051 869916317
21557 21559 882107330
43939 43940 906862353
13835 13837 750774554
85358 85360 468362257
42743 42745 653927711
25898 25900 427788655
9457 9459 600827054
80848 80850 853444790
84751 84753 490887034
142664 142666 26367087...

output:

49897302829745

result:

ok answer is '49897302829745'

Test #5:

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

input:

100000 133332
94634 94636 273916875
49405 49406 7705623
46579 46580 613041575
97379 97381 277397584
86487 86488 446200817
7618 7619 82676219
79763 79765 265220769
49775 49777 175656241
50253 50254 509685344
64341 64342 642442592
81789 81790 7720070
59791 59792 190513484
92339 92341 839361674
83696 8...

output:

33346820813893

result:

ok answer is '33346820813893'

Test #6:

score: 0
Accepted
time: 242ms
memory: 54628kb

input:

149998 199996
84723 84724 160637000
143893 143894 382237567
128673 128674 229111160
87169 87171 186600504
103309 103311 415954689
65442 65443 895315674
71846 71848 882228834
69164 69166 953310617
30360 30361 433585279
126633 126634 77552169
102808 102809 858368884
123704 123706 492180159
142672 1426...

output:

49784186835101

result:

ok answer is '49784186835101'

Test #7:

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

input:

10023 20040
1 1646 1646
1 4408 4408
1 4109 4109
4019 10002 4019
1 2876 2876
1 8613 8613
1 2766 2766
1537 10002 1537
1 3584 3584
1 696 696
1 5648 5648
8667 10002 8667
1 9008 9008
6467 10002 6467
1 1231 1231
1 4290 4290
7054 10002 7054
7021 10002 7021
10007 10023 10007
1 4912 4912
1 5670 5670
2352 100...

output:

40008

result:

ok answer is '40008'

Test #8:

score: 0
Accepted
time: 68ms
memory: 11988kb

input:

10023 20040
1339 10023 1339
12 286 286
1407 10023 1407
6795 10023 6795
6033 10023 6033
5577 10023 5577
6788 10023 6788
4065 10023 4065
3640 10023 3640
12 4354 4354
12 6039 6039
84 10023 84
12 1057 1057
7500 10023 7500
2620 10023 2620
4670 10023 4670
12 2987 2987
1628 10023 1628
1954 10023 1954
12 79...

output:

20048

result:

ok answer is '20048'

Test #9:

score: 0
Accepted
time: 431ms
memory: 68820kb

input:

2003 4000
1002 1300 1000000000
1 881 881
1050 2003 1000000000
310 1002 310
52 1002 52
223 1002 223
1002 1151 1000000000
1002 1619 1000000000
1109 2003 1000000000
1 815 815
1 565 565
80 1002 80
1654 2003 1000000000
1556 2003 1000000000
1 887 887
1 10 10
1349 2003 1000000000
1002 1478 1000000000
1071 ...

output:

2000000404

result:

ok answer is '2000000404'

Test #10:

score: -100
Time Limit Exceeded

input:

100001 199980
13628 20001 947212974
50001 56304 751361163
79801 80001 89669673
13146 20001 452181224
70001 76260 180984182
61744 70001 506205944
86270 90001 658175650
70001 73957 985790752
44630 50001 980133138
40001 45798 471804838
1 5816 117814016
49260 50001 539123895
88564 90001 885508707
99971 ...

output:


result: