fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pii pair < int , int >
  5. #define pb push_back
  6. #define mp make_pair
  7. #define mod 1000000009
  8. struct cmp
  9. {
  10. bool operator()(const pair<int , int> &a , const pair<int , int> &b){
  11. return a.first > b.first;
  12. }
  13. };
  14. int main(){
  15. ios::sync_with_stdio(false);
  16. int t;
  17. cin>>t;
  18. while(t--){
  19. int n;
  20. cin>>n;
  21. string s;
  22. vector<int> graph[n+9];
  23. vector<vector<int> > cost(n+1 , vector<int>(n+1 , 0));
  24. map<string, int> map_name;
  25. for(int i = 1 ; i <= n ; i++){
  26. cin>>s;
  27. map_name[s] = i;
  28. int path , k , c;
  29. cin>>path;
  30. for(int j = 0 ; j < path ; j++){
  31. cin>>k>>c;
  32. graph[i].pb(k);
  33. cost[i][k] = c;
  34. }
  35. }
  36. int k;
  37. cin>>k;
  38. while(k--){
  39. char source_temp[12] , dest_temp[12];
  40. string source , dest;
  41. source.assign(source_temp);
  42. dest.assign(dest_temp);
  43. cin>>source>>dest;
  44. priority_queue<pii , vector<pii >, cmp > pq;
  45. ll dist[n+9];
  46. fill(dist , dist+n , INT_MAX-100000);
  47. int dist_num = map_name[dest] , source_num = map_name[source];
  48. dist[source_num] = 0;
  49. pq.push(mp(0 , source_num));
  50. while(!pq.empty()){
  51. int wt = pq.top().first;
  52. int node = pq.top().second;
  53. pq.pop();
  54. if(node == dist_num){
  55. cout<<wt<<endl;
  56. break;
  57. }
  58. for(auto it:graph[node]){
  59. if(dist[it] > dist[node] + cost[node][it]){
  60. dist[it] = dist[node] + cost[node][it];
  61. pq.push(mp(dist[it] , it));
  62. }
  63. }
  64. }
  65. }
  66. }
  67.  
  68. return 0;
  69. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
50
zikxebb
29
4 42
7 11
8 18
9 48
10 42
12 7
16 18
17 17
18 41
19 24
20 28
21 42
23 22
26 9
27 30
28 5
29 26
31 47
32 13
33 35
37 21
38 41
39 31
40 28
42 27
43 19
47 32
48 3
49 48
kcda
21
1 39
4 6
7 31
8 15
9 2
10 28
11 32
12 40
18 35
23 39
24 28
32 35
34 10
35 38
38 19
42 8
44 43
47 7
48 10
49 45
50 38
wefzxwkzp
14
2 40
8 21
9 13
15 6
16 1
24 21
31 47
33 9
34 15
35 30
36 4
38 36
41 9
47 30
enonw
27
1 49
2 32
3 48
5 34
10 46
11 1
13 31
16 20
18 41
21 30
24 17
25 8
26 36
28 28
30 36
31 30
32 25
34 35
38 29
39 30
41 26
42 5
45 47
47 42
48 16
49 33
50 11
kzdtlun
12
2 12
6 48
12 42
15 2
20 17
21 40
26 33
36 35
37 7
43 17
44 20
46 18
dbacx
34
1 45
3 24
7 11
8 40
9 13
10 38
12 21
13 49
14 2
15 38
16 31
17 5
18 36
19 45
21 1
22 49
23 48
24 10
27 41
28 33
31 11
32 31
33 21
34 22
35 27
36 14
37 17
38 12
41 3
46 45
47 16
48 17
49 40
50 30
dsmco
30
1 33
3 13
4 47
5 39
6 10
9 21
13 33
14 1
15 40
19 26
20 27
21 36
23 15
24 41
25 19
26 1
29 15
30 45
31 5
34 49
35 43
37 9
39 26
40 36
43 26
44 44
46 24
47 49
48 29
50 22
uriqvqfnu
23
1 45
6 47
7 13
10 5
11 45
12 7
14 14
15 34
17 36
18 33
19 6
22 39
23 41
25 32
26 13
28 35
29 39
36 3
37 11
39 19
47 45
48 34
49 23
bznmovlfbm
30
1 22
2 40
3 21
4 36
5 47
6 1
10 33
11 47
12 36
14 36
15 24
17 41
19 7
20 47
24 7
25 24
26 48
27 4
31 35
33 7
34 31
38 47
41 23
43 4
44 8
45 9
46 23
48 7
49 43
50 23
mipgpfabn
23
1 7
3 20
4 43
5 11
7 35
8 23
9 45
12 13
14 21
17 3
18 40
25 28
26 2
27 18
29 30
35 45
40 22
41 5
42 25
44 24
45 2
47 21
48 23
eaqfpguwg
3
18 12
22 34
40 2
tegd
18
2 49
4 10
5 36
6 9
8 3
15 13
17 15
27 22
28 49
31 49
33 17
38 12
39 12
41 33
42 43
45 11
48 16
49 12
cvsthol
25
1 24
3 49
4 45
6 47
7 46
8 30
11 49
12 16
14 47
17 11
20 8
21 31
22 40
24 1
25 43
29 11
30 25
31 34
33 27
34 38
40 35
42 14
44 36
49 35
50 37
mkliqju
27
4 38
8 48
9 29
10 12
15 41
16 15
17 3
19 48
20 38
23 20
25 48
26 49
27 18
30 42
31 5
33 17
34 12
35 12
37 31
40 15
41 4
42 44
44 38
46 9
48 18
49 9
50 11
hwpdx
16
1 21
3 47
4 43
5 25
6 42
7 42
9 6
14 48
19 15
20 14
24 3
25 4
33 23
38 28
45 12
49 5
rpqjysihmc
11
4 31
8 13
11 24
29 30
30 38
33 21
35 13
39 26
40 28
44 35
49 40
kdkq
11
1 36
13 3
18 42
23 19
26 19
28 21
29 17
32 26
36 33
48 14
50 14
vcqsnvzq
4
4 10
7 33
24 49
41 18
ixysjar
34
1 33
2 20
4 2
5 43
8 27
9 43
10 1
11 42
12 36
13 41
14 13
16 8
17 38
18 49
20 32
21 32
24 31
25 8
26 2
27 21
28 30
31 46
32 23
33 49
36 34
37 29
38 45
39 47
40 21
41 45
42 11
43 31
46 44
47 14
opzojcllva
27
1 17
3 32
6 26
7 4
8 40
12 38
13 4
16 23
17 8
18 43
19 42
21 15
24 38
26 7
28 7
29 40
33 23
34 12
36 48
41 29
42 9
43 6
44 14
45 24
47 32
49 5
50 28
xejtpx
32
1 11
2 36
3 16
4 44
5 11
6 10
8 35
9 42
10 24
11 12
12 21
13 3
15 24
16 48
17 32
18 30
19 38
23 10
24 49
28 17
31 36
32 11
34 22
36 30
40 38
41 49
42 43
43 14
44 19
45 38
47 1
49 32
gnaczr
21
1 32
2 31
3 47
9 8
10 16
11 46
13 30
16 23
17 9
27 6
30 49
31 45
33 42
36 37
39 19
40 16
44 1
45 25
46 11
48 2
49 21
ekbo
20
1 11
2 31
5 27
6 44
8 9
9 45
12 31
14 7
15 1
16 42
18 25
20 16
22 37
25 22
30 35
34 23
42 14
43 24
48 23
50 22
lfyhxfodip
26
2 16
3 7
4 47
5 23
8 17
10 22
13 30
14 4
16 17
18 4
19 13
20 5
21 43
23 32
30 48
32 39
34 13
36 10
39 21
40 40
42 37
43 15
44 22
46 32
47 45
48 7
eoqzm
19
2 48
3 44
10 8
12 25
16 19
17 39
18 12
21 2
24 27
29 20
30 35
33 35
36 22
41 2
42 4
43 13
45 41
47 46
48 28
sgphifdakv
16
1 12
2 19
9 18
16 44
19 12
21 21
22 24
23 44
25 16
28 15
32 34
34 10
36 26
37 49
44 46
50 42
lrwrurrvl
21
2 16
4 3
6 9
8 37
14 38
15 36
16 6
17 40
18 40
22 42
24 7
29 4
32 30
34 49
35 24
37 39
38 19
43 25
44 12
45 30
46 26
qowdfywhss
32
2 32
3 26
4 29
5 39
6 6
7 8
8 18
10 7
11 18
13 24
14 46
15 44
16 1
17 11
18 30
19 49
20 17
21 21
24 48
29 7
30 20
31 42
32 8
33 33
35 36
36 13
37 32
39 37
45 12
46 10
48 45
49 24
dfctsgnpm
19
1 20
7 5
12 24
13 31
15 47
20 19
22 41
23 8
28 17
30 15
34 36
35 26
36 22
38 26
40 15
41 24
43 3
44 17
50 44
kgajie
12
4 7
11 4
14 18
17 42
21 19
26 10
28 39
34 18
35 35
36 18
40 10
41 19
kwpsjpkx
12
7 25
16 14
17 36
19 29
21 46
29 22
33 43
34 41
38 13
39 41
45 39
49 31
vjierxcm
7
20 41
21 14
23 34
27 18
28 33
37 48
46 42
ckjwxhkscy
4
4 26
20 6
44 16
47 45
lusmm
18
3 36
5 45
6 45
9 5
10 23
13 3
16 30
20 8
25 32
26 6
30 30
35 24
38 21
41 21
42 25
44 28
48 34
49 18
lyuohugbm
15
7 43
9 39
12 37
18 31
19 6
20 20
24 42
25 46
27 47
32 37
34 13
42 44
43 11
44 46
49 12
prxot
6
1 31
6 46
18 32
29 47
35 33
50 15
ygdnvd
10
10 28
13 22
25 13
27 2
31 13
33 22
39 4
41 43
42 41
46 12
jrfmsl
15
1 28
6 11
11 12
13 10
16 19
22 40
24 36
25 17
26 39
27 41
39 49
44 30
45 35
46 48
47 33
hcxczgmcqe
16
9 13
10 10
11 17
14 13
17 5
19 30
23 7
25 2
26 48
27 10
32 45
36 43
42 21
45 45
46 49
47 39
lpjaorbtdo
27
4 16
9 21
12 39
14 24
15 46
17 21
19 43
20 43
21 16
22 22
23 28
25 17
26 23
27 33
31 30
33 21
35 12
36 34
37 40
38 22
39 19
41 22
42 37
44 1
45 3
46 20
47 39
wvdnv
23
1 35
3 47
8 10
9 42
12 32
14 2
15 3
16 37
19 17
24 47
25 47
27 40
28 44
30 40
31 11
33 10
34 2
35 23
39 17
40 23
42 34
45 23
48 41
rvpqngs
27
2 46
4 49
7 19
10 44
12 11
14 40
15 39
16 23
17 11
18 40
21 38
22 17
23 49
24 37
26 47
27 39
29 5
31 18
33 45
35 15
39 1
40 24
44 42
45 32
46 21
48 2
49 35
gtedmxhrny
24
1 14
3 20
9 37
13 9
14 42
15 19
19 49
20 5
21 33
23 43
24 33
26 14
27 14
29 11
31 39
35 45
40 39
41 8
42 24
44 3
45 47
46 32
47 36
48 25
kkngpniqws
7
1 30
2 12
17 49
19 39
20 20
42 12
50 21
jzyu
13
1 13
4 19
6 7
13 45
17 33
20 36
21 13
25 19
26 5
31 20
35 38
39 11
44 30
yukl
19
4 21
7 24
8 7
13 35
14 47
16 18
22 46
24 41
27 33
28 46
29 47
32 27
34 7
35 20
39 19
42 8
44 15
45 1
48 44
xruuh
26
2 49
5 16
6 38
7 43
10 26
11 17
12 10
16 28
20 4
23 47
26 8
27 47
28 6
29 39
30 41
31 44
33 33
34 9
36 47
38 5
40 18
41 13
42 10
44 26
46 38
50 4
lmxipobm
16
1 22
5 21
6 34
10 13
21 3
22 27
23 44
26 1
29 19
32 47
33 33
35 43
41 33
42 16
43 12
45 34
rvgdzxqt
23
1 18
3 2
5 33
7 16
13 13
18 31
19 9
20 39
21 41
23 17
24 13
26 43
28 40
29 35
30 16
31 35
32 32
33 7
34 30
35 9
36 16
45 24
47 43
beczikn
7
10 23
15 26
29 17
35 3
39 20
43 4
46 48
6
ckjwxhkscy tegd
jrfmsl vcqsnvzq
yukl hwpdx
bznmovlfbm rvpqngs
kkngpniqws mipgpfabn
ixysjar enonw
compilation info
prog.cpp: In function 'int main()':
prog.cpp:58:26: error: 'it' does not name a type
                 for(auto it:graph[node]){
                          ^
prog.cpp:64:13: error: expected ';' before '}' token
             }
             ^
prog.cpp:64:13: error: expected primary-expression before '}' token
prog.cpp:64:13: error: expected ';' before '}' token
prog.cpp:64:13: error: expected primary-expression before '}' token
prog.cpp:64:13: error: expected ')' before '}' token
prog.cpp:64:13: error: expected primary-expression before '}' token
stdout
Standard output is empty