# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292905 | 2020-09-07T14:42:34 Z | 문홍윤(#5817) | 급행열차 20/19 (ROI19_express) | C++17 | 5000 ms | 182380 KB |
#include <bits/stdc++.h> #define mp make_pair #define eb emplace_back #define F first #define S second #define all(x) x.begin(), x.end() #define svec(x) sort(all(x)) #define press(x) x.erase(unique(all(x)), x.end()); using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<int, LL> pil; typedef pair<LL, int> pli; typedef pair<LL, LL> pll; const int INF=1e9; const LL LLINF=5e15; int n, m, q, indeg[500010]; int topo[500010], re, fr; LL p; vector<pil> link[500010], rlink[500010]; vector<LL> dp[500010]; char str[500010]; void cl(int num, int qu){ re=fr=0; for(int i=1; i<=num; i++){ vector<pil>().swap(link[i]); vector<pil>().swap(rlink[i]); vector<LL>().swap(dp[i]); } for(int i=1; i<=qu; i++)str[i]=0; } void merge_dp(int num){ int sz=rlink[num].size(); LL st=0; vector<int> pv(sz); vector<LL> tmp; while(1){ LL minn=LLINF; int minnum=-1; for(int i=0; i<pv.size(); i++){ int nw=rlink[num][i].F; LL c=rlink[num][i].S; if(pv[i]==dp[nw].size())continue; if(minn>dp[nw][pv[i]]+c){ minn=dp[nw][pv[i]]+c; minnum=i; } } if(minnum==-1)break; if(st*p/(p-1)<minn){ tmp.eb(minn); tmp.eb(minn); st=minn; } else tmp[tmp.size()-1]=minn; pv[minnum]++; } press(tmp); dp[num].resize(tmp.size()); for(int i=0; i<tmp.size(); i++)dp[num][i]=tmp[i]; } void solve(){ scanf("%d %d %d %lld", &n, &m, &q, &p); for(int i=1; i<=m; i++){ int a, b; LL c; scanf("%d %d %lld", &a, &b, &c); link[a].eb(b, c); rlink[b].eb(a, c); indeg[b]++; } for(int i=1; i<=n; i++){ if(!indeg[i])topo[++re]=i; } for(fr=1; fr<=re; fr++){ for(auto i:link[topo[fr]]){ indeg[i.F]--; if(!indeg[i.F])topo[++re]=i.F; } } dp[1].eb(0); for(int i=2; i<=n; i++)merge_dp(topo[i]); for(int i=1; i<=q; i++){ int a; LL s, e; scanf("%d %lld", &a, &s); e=s*p/(p-1); int num=upper_bound(all(dp[a]), e)-lower_bound(all(dp[a]), s); if(num)str[i]='1'; else str[i]='0'; } printf("%s\n", str+1); cl(n, q); } int main(){ int t; scanf("%d", &t); while(t--)solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 35584 KB | Output is correct |
2 | Correct | 23 ms | 35584 KB | Output is correct |
3 | Correct | 25 ms | 35584 KB | Output is correct |
4 | Correct | 24 ms | 35584 KB | Output is correct |
5 | Correct | 31 ms | 35576 KB | Output is correct |
6 | Correct | 23 ms | 35584 KB | Output is correct |
7 | Correct | 25 ms | 35584 KB | Output is correct |
8 | Correct | 24 ms | 35584 KB | Output is correct |
9 | Correct | 23 ms | 35584 KB | Output is correct |
10 | Correct | 23 ms | 35584 KB | Output is correct |
11 | Correct | 22 ms | 35584 KB | Output is correct |
12 | Correct | 33 ms | 35584 KB | Output is correct |
13 | Correct | 35 ms | 35584 KB | Output is correct |
14 | Correct | 36 ms | 35628 KB | Output is correct |
15 | Correct | 34 ms | 35584 KB | Output is correct |
16 | Correct | 33 ms | 35616 KB | Output is correct |
17 | Correct | 34 ms | 35584 KB | Output is correct |
18 | Correct | 35 ms | 35584 KB | Output is correct |
19 | Correct | 35 ms | 35584 KB | Output is correct |
20 | Correct | 35 ms | 35584 KB | Output is correct |
21 | Correct | 35 ms | 35584 KB | Output is correct |
22 | Correct | 34 ms | 35584 KB | Output is correct |
23 | Correct | 33 ms | 35584 KB | Output is correct |
24 | Correct | 35 ms | 35576 KB | Output is correct |
25 | Correct | 32 ms | 35584 KB | Output is correct |
26 | Correct | 31 ms | 35584 KB | Output is correct |
27 | Correct | 31 ms | 35712 KB | Output is correct |
28 | Correct | 32 ms | 35584 KB | Output is correct |
29 | Correct | 33 ms | 35584 KB | Output is correct |
30 | Correct | 32 ms | 35584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 35584 KB | Output is correct |
2 | Correct | 25 ms | 35584 KB | Output is correct |
3 | Correct | 24 ms | 35584 KB | Output is correct |
4 | Correct | 25 ms | 35584 KB | Output is correct |
5 | Correct | 25 ms | 35584 KB | Output is correct |
6 | Correct | 25 ms | 35584 KB | Output is correct |
7 | Correct | 25 ms | 35584 KB | Output is correct |
8 | Correct | 24 ms | 35584 KB | Output is correct |
9 | Correct | 24 ms | 35584 KB | Output is correct |
10 | Correct | 30 ms | 35704 KB | Output is correct |
11 | Correct | 42 ms | 36088 KB | Output is correct |
12 | Correct | 32 ms | 35968 KB | Output is correct |
13 | Correct | 34 ms | 36096 KB | Output is correct |
14 | Correct | 29 ms | 35584 KB | Output is correct |
15 | Correct | 29 ms | 35584 KB | Output is correct |
16 | Correct | 29 ms | 35576 KB | Output is correct |
17 | Correct | 31 ms | 35584 KB | Output is correct |
18 | Correct | 29 ms | 35584 KB | Output is correct |
19 | Correct | 29 ms | 35584 KB | Output is correct |
20 | Correct | 29 ms | 35584 KB | Output is correct |
21 | Correct | 30 ms | 35576 KB | Output is correct |
22 | Correct | 30 ms | 35968 KB | Output is correct |
23 | Correct | 31 ms | 35968 KB | Output is correct |
24 | Correct | 28 ms | 35584 KB | Output is correct |
25 | Correct | 29 ms | 35712 KB | Output is correct |
26 | Correct | 31 ms | 35584 KB | Output is correct |
27 | Correct | 30 ms | 35584 KB | Output is correct |
28 | Correct | 26 ms | 35576 KB | Output is correct |
29 | Correct | 28 ms | 35584 KB | Output is correct |
30 | Correct | 27 ms | 35584 KB | Output is correct |
31 | Correct | 28 ms | 35584 KB | Output is correct |
32 | Correct | 920 ms | 38812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 35584 KB | Output is correct |
2 | Correct | 684 ms | 67772 KB | Output is correct |
3 | Correct | 596 ms | 43208 KB | Output is correct |
4 | Correct | 497 ms | 39416 KB | Output is correct |
5 | Correct | 407 ms | 36500 KB | Output is correct |
6 | Correct | 624 ms | 47736 KB | Output is correct |
7 | Correct | 542 ms | 42104 KB | Output is correct |
8 | Correct | 629 ms | 48120 KB | Output is correct |
9 | Correct | 628 ms | 41848 KB | Output is correct |
10 | Correct | 608 ms | 47792 KB | Output is correct |
11 | Correct | 521 ms | 41592 KB | Output is correct |
12 | Correct | 143 ms | 35712 KB | Output is correct |
13 | Correct | 31 ms | 35584 KB | Output is correct |
14 | Correct | 32 ms | 35584 KB | Output is correct |
15 | Correct | 36 ms | 35576 KB | Output is correct |
16 | Correct | 36 ms | 35584 KB | Output is correct |
17 | Correct | 52 ms | 35712 KB | Output is correct |
18 | Correct | 179 ms | 36344 KB | Output is correct |
19 | Correct | 46 ms | 35584 KB | Output is correct |
20 | Correct | 71 ms | 35704 KB | Output is correct |
21 | Correct | 69 ms | 35584 KB | Output is correct |
22 | Correct | 70 ms | 35648 KB | Output is correct |
23 | Correct | 397 ms | 91128 KB | Output is correct |
24 | Correct | 1002 ms | 182380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 35584 KB | Output is correct |
2 | Correct | 684 ms | 67772 KB | Output is correct |
3 | Correct | 596 ms | 43208 KB | Output is correct |
4 | Correct | 497 ms | 39416 KB | Output is correct |
5 | Correct | 407 ms | 36500 KB | Output is correct |
6 | Correct | 624 ms | 47736 KB | Output is correct |
7 | Correct | 542 ms | 42104 KB | Output is correct |
8 | Correct | 629 ms | 48120 KB | Output is correct |
9 | Correct | 628 ms | 41848 KB | Output is correct |
10 | Correct | 608 ms | 47792 KB | Output is correct |
11 | Correct | 521 ms | 41592 KB | Output is correct |
12 | Correct | 143 ms | 35712 KB | Output is correct |
13 | Correct | 31 ms | 35584 KB | Output is correct |
14 | Correct | 32 ms | 35584 KB | Output is correct |
15 | Correct | 36 ms | 35576 KB | Output is correct |
16 | Correct | 36 ms | 35584 KB | Output is correct |
17 | Correct | 52 ms | 35712 KB | Output is correct |
18 | Correct | 179 ms | 36344 KB | Output is correct |
19 | Correct | 46 ms | 35584 KB | Output is correct |
20 | Correct | 71 ms | 35704 KB | Output is correct |
21 | Correct | 69 ms | 35584 KB | Output is correct |
22 | Correct | 70 ms | 35648 KB | Output is correct |
23 | Correct | 397 ms | 91128 KB | Output is correct |
24 | Correct | 1002 ms | 182380 KB | Output is correct |
25 | Incorrect | 928 ms | 70324 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 35584 KB | Output is correct |
2 | Correct | 25 ms | 35584 KB | Output is correct |
3 | Correct | 26 ms | 35584 KB | Output is correct |
4 | Correct | 30 ms | 35712 KB | Output is correct |
5 | Correct | 25 ms | 35584 KB | Output is correct |
6 | Correct | 26 ms | 35576 KB | Output is correct |
7 | Correct | 26 ms | 35584 KB | Output is correct |
8 | Correct | 29 ms | 36600 KB | Output is correct |
9 | Correct | 28 ms | 35584 KB | Output is correct |
10 | Correct | 26 ms | 35576 KB | Output is correct |
11 | Correct | 28 ms | 35584 KB | Output is correct |
12 | Correct | 27 ms | 35584 KB | Output is correct |
13 | Correct | 27 ms | 35584 KB | Output is correct |
14 | Correct | 28 ms | 35584 KB | Output is correct |
15 | Correct | 28 ms | 35712 KB | Output is correct |
16 | Correct | 27 ms | 35584 KB | Output is correct |
17 | Correct | 30 ms | 35712 KB | Output is correct |
18 | Correct | 31 ms | 36216 KB | Output is correct |
19 | Correct | 26 ms | 35704 KB | Output is correct |
20 | Correct | 30 ms | 36224 KB | Output is correct |
21 | Correct | 32 ms | 36352 KB | Output is correct |
22 | Correct | 28 ms | 35960 KB | Output is correct |
23 | Correct | 30 ms | 36096 KB | Output is correct |
24 | Correct | 29 ms | 35960 KB | Output is correct |
25 | Correct | 31 ms | 36476 KB | Output is correct |
26 | Correct | 25 ms | 35584 KB | Output is correct |
27 | Correct | 25 ms | 35584 KB | Output is correct |
28 | Correct | 25 ms | 35584 KB | Output is correct |
29 | Correct | 25 ms | 35576 KB | Output is correct |
30 | Correct | 25 ms | 35584 KB | Output is correct |
31 | Correct | 25 ms | 35584 KB | Output is correct |
32 | Correct | 26 ms | 35584 KB | Output is correct |
33 | Correct | 25 ms | 35576 KB | Output is correct |
34 | Correct | 27 ms | 35584 KB | Output is correct |
35 | Correct | 27 ms | 35576 KB | Output is correct |
36 | Correct | 28 ms | 35584 KB | Output is correct |
37 | Correct | 27 ms | 35584 KB | Output is correct |
38 | Correct | 27 ms | 35584 KB | Output is correct |
39 | Correct | 27 ms | 35584 KB | Output is correct |
40 | Correct | 27 ms | 35584 KB | Output is correct |
41 | Correct | 27 ms | 35576 KB | Output is correct |
42 | Correct | 30 ms | 35584 KB | Output is correct |
43 | Correct | 40 ms | 38264 KB | Output is correct |
44 | Correct | 40 ms | 38568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 35584 KB | Output is correct |
2 | Correct | 25 ms | 35584 KB | Output is correct |
3 | Correct | 26 ms | 35584 KB | Output is correct |
4 | Correct | 30 ms | 35712 KB | Output is correct |
5 | Correct | 25 ms | 35584 KB | Output is correct |
6 | Correct | 26 ms | 35576 KB | Output is correct |
7 | Correct | 26 ms | 35584 KB | Output is correct |
8 | Correct | 29 ms | 36600 KB | Output is correct |
9 | Correct | 28 ms | 35584 KB | Output is correct |
10 | Correct | 26 ms | 35576 KB | Output is correct |
11 | Correct | 28 ms | 35584 KB | Output is correct |
12 | Correct | 27 ms | 35584 KB | Output is correct |
13 | Correct | 27 ms | 35584 KB | Output is correct |
14 | Correct | 28 ms | 35584 KB | Output is correct |
15 | Correct | 28 ms | 35712 KB | Output is correct |
16 | Correct | 27 ms | 35584 KB | Output is correct |
17 | Correct | 30 ms | 35712 KB | Output is correct |
18 | Correct | 31 ms | 36216 KB | Output is correct |
19 | Correct | 26 ms | 35704 KB | Output is correct |
20 | Correct | 30 ms | 36224 KB | Output is correct |
21 | Correct | 32 ms | 36352 KB | Output is correct |
22 | Correct | 28 ms | 35960 KB | Output is correct |
23 | Correct | 30 ms | 36096 KB | Output is correct |
24 | Correct | 29 ms | 35960 KB | Output is correct |
25 | Correct | 31 ms | 36476 KB | Output is correct |
26 | Correct | 25 ms | 35584 KB | Output is correct |
27 | Correct | 25 ms | 35584 KB | Output is correct |
28 | Correct | 25 ms | 35584 KB | Output is correct |
29 | Correct | 25 ms | 35576 KB | Output is correct |
30 | Correct | 25 ms | 35584 KB | Output is correct |
31 | Correct | 25 ms | 35584 KB | Output is correct |
32 | Correct | 26 ms | 35584 KB | Output is correct |
33 | Correct | 25 ms | 35576 KB | Output is correct |
34 | Correct | 27 ms | 35584 KB | Output is correct |
35 | Correct | 27 ms | 35576 KB | Output is correct |
36 | Correct | 28 ms | 35584 KB | Output is correct |
37 | Correct | 27 ms | 35584 KB | Output is correct |
38 | Correct | 27 ms | 35584 KB | Output is correct |
39 | Correct | 27 ms | 35584 KB | Output is correct |
40 | Correct | 27 ms | 35584 KB | Output is correct |
41 | Correct | 27 ms | 35576 KB | Output is correct |
42 | Correct | 30 ms | 35584 KB | Output is correct |
43 | Correct | 40 ms | 38264 KB | Output is correct |
44 | Correct | 40 ms | 38568 KB | Output is correct |
45 | Correct | 1006 ms | 45048 KB | Output is correct |
46 | Correct | 2780 ms | 89464 KB | Output is correct |
47 | Correct | 1294 ms | 80032 KB | Output is correct |
48 | Correct | 738 ms | 36856 KB | Output is correct |
49 | Correct | 1059 ms | 36840 KB | Output is correct |
50 | Correct | 728 ms | 36216 KB | Output is correct |
51 | Correct | 25 ms | 35584 KB | Output is correct |
52 | Correct | 25 ms | 35576 KB | Output is correct |
53 | Correct | 63 ms | 35584 KB | Output is correct |
54 | Correct | 41 ms | 35584 KB | Output is correct |
55 | Correct | 609 ms | 36356 KB | Output is correct |
56 | Correct | 1474 ms | 36944 KB | Output is correct |
57 | Correct | 850 ms | 36472 KB | Output is correct |
58 | Correct | 723 ms | 36864 KB | Output is correct |
59 | Correct | 1362 ms | 36584 KB | Output is correct |
60 | Correct | 612 ms | 37812 KB | Output is correct |
61 | Correct | 1381 ms | 55076 KB | Output is correct |
62 | Execution timed out | 5044 ms | 57720 KB | Time limit exceeded |
63 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 35584 KB | Output is correct |
2 | Correct | 23 ms | 35584 KB | Output is correct |
3 | Correct | 25 ms | 35584 KB | Output is correct |
4 | Correct | 24 ms | 35584 KB | Output is correct |
5 | Correct | 31 ms | 35576 KB | Output is correct |
6 | Correct | 23 ms | 35584 KB | Output is correct |
7 | Correct | 25 ms | 35584 KB | Output is correct |
8 | Correct | 24 ms | 35584 KB | Output is correct |
9 | Correct | 23 ms | 35584 KB | Output is correct |
10 | Correct | 23 ms | 35584 KB | Output is correct |
11 | Correct | 22 ms | 35584 KB | Output is correct |
12 | Correct | 33 ms | 35584 KB | Output is correct |
13 | Correct | 35 ms | 35584 KB | Output is correct |
14 | Correct | 36 ms | 35628 KB | Output is correct |
15 | Correct | 34 ms | 35584 KB | Output is correct |
16 | Correct | 33 ms | 35616 KB | Output is correct |
17 | Correct | 34 ms | 35584 KB | Output is correct |
18 | Correct | 35 ms | 35584 KB | Output is correct |
19 | Correct | 35 ms | 35584 KB | Output is correct |
20 | Correct | 35 ms | 35584 KB | Output is correct |
21 | Correct | 35 ms | 35584 KB | Output is correct |
22 | Correct | 34 ms | 35584 KB | Output is correct |
23 | Correct | 33 ms | 35584 KB | Output is correct |
24 | Correct | 35 ms | 35576 KB | Output is correct |
25 | Correct | 32 ms | 35584 KB | Output is correct |
26 | Correct | 31 ms | 35584 KB | Output is correct |
27 | Correct | 31 ms | 35712 KB | Output is correct |
28 | Correct | 32 ms | 35584 KB | Output is correct |
29 | Correct | 33 ms | 35584 KB | Output is correct |
30 | Correct | 32 ms | 35584 KB | Output is correct |
31 | Correct | 24 ms | 35584 KB | Output is correct |
32 | Correct | 25 ms | 35584 KB | Output is correct |
33 | Correct | 24 ms | 35584 KB | Output is correct |
34 | Correct | 25 ms | 35584 KB | Output is correct |
35 | Correct | 25 ms | 35584 KB | Output is correct |
36 | Correct | 25 ms | 35584 KB | Output is correct |
37 | Correct | 25 ms | 35584 KB | Output is correct |
38 | Correct | 24 ms | 35584 KB | Output is correct |
39 | Correct | 24 ms | 35584 KB | Output is correct |
40 | Correct | 30 ms | 35704 KB | Output is correct |
41 | Correct | 42 ms | 36088 KB | Output is correct |
42 | Correct | 32 ms | 35968 KB | Output is correct |
43 | Correct | 34 ms | 36096 KB | Output is correct |
44 | Correct | 29 ms | 35584 KB | Output is correct |
45 | Correct | 29 ms | 35584 KB | Output is correct |
46 | Correct | 29 ms | 35576 KB | Output is correct |
47 | Correct | 31 ms | 35584 KB | Output is correct |
48 | Correct | 29 ms | 35584 KB | Output is correct |
49 | Correct | 29 ms | 35584 KB | Output is correct |
50 | Correct | 29 ms | 35584 KB | Output is correct |
51 | Correct | 30 ms | 35576 KB | Output is correct |
52 | Correct | 30 ms | 35968 KB | Output is correct |
53 | Correct | 31 ms | 35968 KB | Output is correct |
54 | Correct | 28 ms | 35584 KB | Output is correct |
55 | Correct | 29 ms | 35712 KB | Output is correct |
56 | Correct | 31 ms | 35584 KB | Output is correct |
57 | Correct | 30 ms | 35584 KB | Output is correct |
58 | Correct | 26 ms | 35576 KB | Output is correct |
59 | Correct | 28 ms | 35584 KB | Output is correct |
60 | Correct | 27 ms | 35584 KB | Output is correct |
61 | Correct | 28 ms | 35584 KB | Output is correct |
62 | Correct | 920 ms | 38812 KB | Output is correct |
63 | Correct | 24 ms | 35584 KB | Output is correct |
64 | Correct | 684 ms | 67772 KB | Output is correct |
65 | Correct | 596 ms | 43208 KB | Output is correct |
66 | Correct | 497 ms | 39416 KB | Output is correct |
67 | Correct | 407 ms | 36500 KB | Output is correct |
68 | Correct | 624 ms | 47736 KB | Output is correct |
69 | Correct | 542 ms | 42104 KB | Output is correct |
70 | Correct | 629 ms | 48120 KB | Output is correct |
71 | Correct | 628 ms | 41848 KB | Output is correct |
72 | Correct | 608 ms | 47792 KB | Output is correct |
73 | Correct | 521 ms | 41592 KB | Output is correct |
74 | Correct | 143 ms | 35712 KB | Output is correct |
75 | Correct | 31 ms | 35584 KB | Output is correct |
76 | Correct | 32 ms | 35584 KB | Output is correct |
77 | Correct | 36 ms | 35576 KB | Output is correct |
78 | Correct | 36 ms | 35584 KB | Output is correct |
79 | Correct | 52 ms | 35712 KB | Output is correct |
80 | Correct | 179 ms | 36344 KB | Output is correct |
81 | Correct | 46 ms | 35584 KB | Output is correct |
82 | Correct | 71 ms | 35704 KB | Output is correct |
83 | Correct | 69 ms | 35584 KB | Output is correct |
84 | Correct | 70 ms | 35648 KB | Output is correct |
85 | Correct | 397 ms | 91128 KB | Output is correct |
86 | Correct | 1002 ms | 182380 KB | Output is correct |
87 | Incorrect | 928 ms | 70324 KB | Output isn't correct |
88 | Halted | 0 ms | 0 KB | - |