# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
430185 |
2021-06-16T11:57:21 Z |
최서현(#7488) |
Brackets (CPSPC17_brackets) |
C++17 |
|
216 ms |
135400 KB |
#include <iostream>
#include <vector>
#include <queue>
#define pii pair<int, int>
#define piii pair<int, pii>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
using namespace std;
const int INF = (int)1e9 + 7;
const int MAX = 4040404;
vector<int> gph[202][8];
vector<int> rgph[202][8];
vector<pii> Q[MAX];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("in.txt", "r", stdin);
int n, m, s, e; cin >> n >> m >> s >> e; --s; --e;
for(int i = 0; i < m; ++i)
{
int x, y; char c; cin >> x >> y >> c; --x; --y;
int z;
if(c == '<') z = 0;
if(c == '>') z = 1;
if(c == '{') z = 2;
if(c == '}') z = 3;
if(c == '[') z = 4;
if(c == ']') z = 5;
if(c == '(') z = 6;
if(c == ')') z = 7;
gph[x][z].push_back(y);
rgph[y][z].push_back(x);
}
int C[n][n];
for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) C[i][j] = INF;
for(int i = 0; i < n; ++i) Q[0].push_back({i, i});
for(int d = 0; d < MAX - 2; d += 2)
{
for(auto x : Q[d])
{
if(C[x.ff][x.ss] != INF) continue;
C[x.ff][x.ss] = d;
for(int i = 0; i < 8; i += 2)
for(auto j : rgph[x.ff][i])
for(auto k : gph[x.ss][i + 1])
Q[d + 2].push_back({j, k});
for(int i = 0; i < n; ++i)
{
if(min(MAX, C[i][x.ss]) > C[x.ff][x.ss] + C[i][x.ff])
Q[C[x.ff][x.ss] + C[i][x.ff]].push_back({i, x.ss});
if(min(MAX, C[x.ff][i]) > C[x.ff][x.ss] + C[x.ss][i])
Q[C[x.ff][x.ss] + C[x.ss][i]].push_back({x.ff, i});
}
}
}
// for(int i = 0; i < n; ++i)
// {
// for(int j = 0; j < n; ++j)
// cout << C[i][j] << ' ';
// cout << endl;
// }
cout << (C[s][e] == INF ? -1 : C[s][e]);
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:30:13: warning: 'z' may be used uninitialized in this function [-Wmaybe-uninitialized]
30 | int z;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
95164 KB |
Output is correct |
2 |
Correct |
78 ms |
95248 KB |
Output is correct |
3 |
Correct |
74 ms |
95196 KB |
Output is correct |
4 |
Correct |
74 ms |
95220 KB |
Output is correct |
5 |
Correct |
78 ms |
95192 KB |
Output is correct |
6 |
Correct |
70 ms |
95140 KB |
Output is correct |
7 |
Correct |
81 ms |
95132 KB |
Output is correct |
8 |
Correct |
74 ms |
95188 KB |
Output is correct |
9 |
Correct |
78 ms |
95248 KB |
Output is correct |
10 |
Correct |
73 ms |
95252 KB |
Output is correct |
11 |
Correct |
79 ms |
95256 KB |
Output is correct |
12 |
Correct |
82 ms |
95248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
95164 KB |
Output is correct |
2 |
Correct |
78 ms |
95248 KB |
Output is correct |
3 |
Correct |
74 ms |
95196 KB |
Output is correct |
4 |
Correct |
74 ms |
95220 KB |
Output is correct |
5 |
Correct |
78 ms |
95192 KB |
Output is correct |
6 |
Correct |
70 ms |
95140 KB |
Output is correct |
7 |
Correct |
81 ms |
95132 KB |
Output is correct |
8 |
Correct |
74 ms |
95188 KB |
Output is correct |
9 |
Correct |
78 ms |
95248 KB |
Output is correct |
10 |
Correct |
73 ms |
95252 KB |
Output is correct |
11 |
Correct |
79 ms |
95256 KB |
Output is correct |
12 |
Correct |
82 ms |
95248 KB |
Output is correct |
13 |
Correct |
72 ms |
95260 KB |
Output is correct |
14 |
Correct |
89 ms |
95216 KB |
Output is correct |
15 |
Correct |
73 ms |
95148 KB |
Output is correct |
16 |
Correct |
85 ms |
95152 KB |
Output is correct |
17 |
Correct |
80 ms |
95160 KB |
Output is correct |
18 |
Correct |
79 ms |
95244 KB |
Output is correct |
19 |
Correct |
83 ms |
95172 KB |
Output is correct |
20 |
Correct |
81 ms |
95300 KB |
Output is correct |
21 |
Correct |
75 ms |
95240 KB |
Output is correct |
22 |
Correct |
81 ms |
95320 KB |
Output is correct |
23 |
Correct |
80 ms |
95220 KB |
Output is correct |
24 |
Correct |
74 ms |
95212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
95164 KB |
Output is correct |
2 |
Correct |
78 ms |
95248 KB |
Output is correct |
3 |
Correct |
74 ms |
95196 KB |
Output is correct |
4 |
Correct |
74 ms |
95220 KB |
Output is correct |
5 |
Correct |
78 ms |
95192 KB |
Output is correct |
6 |
Correct |
70 ms |
95140 KB |
Output is correct |
7 |
Correct |
81 ms |
95132 KB |
Output is correct |
8 |
Correct |
74 ms |
95188 KB |
Output is correct |
9 |
Correct |
78 ms |
95248 KB |
Output is correct |
10 |
Correct |
73 ms |
95252 KB |
Output is correct |
11 |
Correct |
79 ms |
95256 KB |
Output is correct |
12 |
Correct |
82 ms |
95248 KB |
Output is correct |
13 |
Correct |
72 ms |
95260 KB |
Output is correct |
14 |
Correct |
89 ms |
95216 KB |
Output is correct |
15 |
Correct |
73 ms |
95148 KB |
Output is correct |
16 |
Correct |
85 ms |
95152 KB |
Output is correct |
17 |
Correct |
80 ms |
95160 KB |
Output is correct |
18 |
Correct |
79 ms |
95244 KB |
Output is correct |
19 |
Correct |
83 ms |
95172 KB |
Output is correct |
20 |
Correct |
81 ms |
95300 KB |
Output is correct |
21 |
Correct |
75 ms |
95240 KB |
Output is correct |
22 |
Correct |
81 ms |
95320 KB |
Output is correct |
23 |
Correct |
80 ms |
95220 KB |
Output is correct |
24 |
Correct |
74 ms |
95212 KB |
Output is correct |
25 |
Correct |
79 ms |
95156 KB |
Output is correct |
26 |
Correct |
76 ms |
95528 KB |
Output is correct |
27 |
Correct |
76 ms |
95532 KB |
Output is correct |
28 |
Correct |
82 ms |
95272 KB |
Output is correct |
29 |
Correct |
78 ms |
95872 KB |
Output is correct |
30 |
Correct |
84 ms |
98564 KB |
Output is correct |
31 |
Correct |
72 ms |
95324 KB |
Output is correct |
32 |
Correct |
76 ms |
95264 KB |
Output is correct |
33 |
Correct |
83 ms |
95504 KB |
Output is correct |
34 |
Correct |
81 ms |
95192 KB |
Output is correct |
35 |
Correct |
80 ms |
97972 KB |
Output is correct |
36 |
Correct |
79 ms |
96152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
95164 KB |
Output is correct |
2 |
Correct |
78 ms |
95248 KB |
Output is correct |
3 |
Correct |
74 ms |
95196 KB |
Output is correct |
4 |
Correct |
74 ms |
95220 KB |
Output is correct |
5 |
Correct |
78 ms |
95192 KB |
Output is correct |
6 |
Correct |
70 ms |
95140 KB |
Output is correct |
7 |
Correct |
81 ms |
95132 KB |
Output is correct |
8 |
Correct |
74 ms |
95188 KB |
Output is correct |
9 |
Correct |
78 ms |
95248 KB |
Output is correct |
10 |
Correct |
73 ms |
95252 KB |
Output is correct |
11 |
Correct |
79 ms |
95256 KB |
Output is correct |
12 |
Correct |
82 ms |
95248 KB |
Output is correct |
13 |
Correct |
72 ms |
95260 KB |
Output is correct |
14 |
Correct |
89 ms |
95216 KB |
Output is correct |
15 |
Correct |
73 ms |
95148 KB |
Output is correct |
16 |
Correct |
85 ms |
95152 KB |
Output is correct |
17 |
Correct |
80 ms |
95160 KB |
Output is correct |
18 |
Correct |
79 ms |
95244 KB |
Output is correct |
19 |
Correct |
83 ms |
95172 KB |
Output is correct |
20 |
Correct |
81 ms |
95300 KB |
Output is correct |
21 |
Correct |
75 ms |
95240 KB |
Output is correct |
22 |
Correct |
81 ms |
95320 KB |
Output is correct |
23 |
Correct |
80 ms |
95220 KB |
Output is correct |
24 |
Correct |
74 ms |
95212 KB |
Output is correct |
25 |
Correct |
79 ms |
95156 KB |
Output is correct |
26 |
Correct |
76 ms |
95528 KB |
Output is correct |
27 |
Correct |
76 ms |
95532 KB |
Output is correct |
28 |
Correct |
82 ms |
95272 KB |
Output is correct |
29 |
Correct |
78 ms |
95872 KB |
Output is correct |
30 |
Correct |
84 ms |
98564 KB |
Output is correct |
31 |
Correct |
72 ms |
95324 KB |
Output is correct |
32 |
Correct |
76 ms |
95264 KB |
Output is correct |
33 |
Correct |
83 ms |
95504 KB |
Output is correct |
34 |
Correct |
81 ms |
95192 KB |
Output is correct |
35 |
Correct |
80 ms |
97972 KB |
Output is correct |
36 |
Correct |
79 ms |
96152 KB |
Output is correct |
37 |
Correct |
75 ms |
95364 KB |
Output is correct |
38 |
Correct |
101 ms |
102152 KB |
Output is correct |
39 |
Correct |
68 ms |
95340 KB |
Output is correct |
40 |
Correct |
74 ms |
95172 KB |
Output is correct |
41 |
Correct |
84 ms |
102196 KB |
Output is correct |
42 |
Correct |
64 ms |
95192 KB |
Output is correct |
43 |
Correct |
77 ms |
95240 KB |
Output is correct |
44 |
Correct |
73 ms |
95312 KB |
Output is correct |
45 |
Correct |
91 ms |
102172 KB |
Output is correct |
46 |
Correct |
91 ms |
102120 KB |
Output is correct |
47 |
Correct |
73 ms |
95436 KB |
Output is correct |
48 |
Correct |
101 ms |
102228 KB |
Output is correct |
49 |
Correct |
83 ms |
95280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
106180 KB |
Output is correct |
2 |
Correct |
124 ms |
106664 KB |
Output is correct |
3 |
Correct |
111 ms |
106220 KB |
Output is correct |
4 |
Correct |
108 ms |
106028 KB |
Output is correct |
5 |
Correct |
109 ms |
105976 KB |
Output is correct |
6 |
Correct |
112 ms |
105772 KB |
Output is correct |
7 |
Correct |
118 ms |
105968 KB |
Output is correct |
8 |
Correct |
110 ms |
106296 KB |
Output is correct |
9 |
Correct |
122 ms |
105620 KB |
Output is correct |
10 |
Correct |
109 ms |
105380 KB |
Output is correct |
11 |
Correct |
111 ms |
105388 KB |
Output is correct |
12 |
Correct |
105 ms |
105292 KB |
Output is correct |
13 |
Correct |
119 ms |
104784 KB |
Output is correct |
14 |
Correct |
74 ms |
95544 KB |
Output is correct |
15 |
Correct |
86 ms |
95456 KB |
Output is correct |
16 |
Correct |
81 ms |
95420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
95164 KB |
Output is correct |
2 |
Correct |
78 ms |
95248 KB |
Output is correct |
3 |
Correct |
74 ms |
95196 KB |
Output is correct |
4 |
Correct |
74 ms |
95220 KB |
Output is correct |
5 |
Correct |
78 ms |
95192 KB |
Output is correct |
6 |
Correct |
70 ms |
95140 KB |
Output is correct |
7 |
Correct |
81 ms |
95132 KB |
Output is correct |
8 |
Correct |
74 ms |
95188 KB |
Output is correct |
9 |
Correct |
78 ms |
95248 KB |
Output is correct |
10 |
Correct |
73 ms |
95252 KB |
Output is correct |
11 |
Correct |
79 ms |
95256 KB |
Output is correct |
12 |
Correct |
82 ms |
95248 KB |
Output is correct |
13 |
Correct |
72 ms |
95260 KB |
Output is correct |
14 |
Correct |
89 ms |
95216 KB |
Output is correct |
15 |
Correct |
73 ms |
95148 KB |
Output is correct |
16 |
Correct |
85 ms |
95152 KB |
Output is correct |
17 |
Correct |
80 ms |
95160 KB |
Output is correct |
18 |
Correct |
79 ms |
95244 KB |
Output is correct |
19 |
Correct |
83 ms |
95172 KB |
Output is correct |
20 |
Correct |
81 ms |
95300 KB |
Output is correct |
21 |
Correct |
75 ms |
95240 KB |
Output is correct |
22 |
Correct |
81 ms |
95320 KB |
Output is correct |
23 |
Correct |
80 ms |
95220 KB |
Output is correct |
24 |
Correct |
74 ms |
95212 KB |
Output is correct |
25 |
Correct |
79 ms |
95156 KB |
Output is correct |
26 |
Correct |
76 ms |
95528 KB |
Output is correct |
27 |
Correct |
76 ms |
95532 KB |
Output is correct |
28 |
Correct |
82 ms |
95272 KB |
Output is correct |
29 |
Correct |
78 ms |
95872 KB |
Output is correct |
30 |
Correct |
84 ms |
98564 KB |
Output is correct |
31 |
Correct |
72 ms |
95324 KB |
Output is correct |
32 |
Correct |
76 ms |
95264 KB |
Output is correct |
33 |
Correct |
83 ms |
95504 KB |
Output is correct |
34 |
Correct |
81 ms |
95192 KB |
Output is correct |
35 |
Correct |
80 ms |
97972 KB |
Output is correct |
36 |
Correct |
79 ms |
96152 KB |
Output is correct |
37 |
Correct |
75 ms |
95364 KB |
Output is correct |
38 |
Correct |
101 ms |
102152 KB |
Output is correct |
39 |
Correct |
68 ms |
95340 KB |
Output is correct |
40 |
Correct |
74 ms |
95172 KB |
Output is correct |
41 |
Correct |
84 ms |
102196 KB |
Output is correct |
42 |
Correct |
64 ms |
95192 KB |
Output is correct |
43 |
Correct |
77 ms |
95240 KB |
Output is correct |
44 |
Correct |
73 ms |
95312 KB |
Output is correct |
45 |
Correct |
91 ms |
102172 KB |
Output is correct |
46 |
Correct |
91 ms |
102120 KB |
Output is correct |
47 |
Correct |
73 ms |
95436 KB |
Output is correct |
48 |
Correct |
101 ms |
102228 KB |
Output is correct |
49 |
Correct |
83 ms |
95280 KB |
Output is correct |
50 |
Correct |
118 ms |
106180 KB |
Output is correct |
51 |
Correct |
124 ms |
106664 KB |
Output is correct |
52 |
Correct |
111 ms |
106220 KB |
Output is correct |
53 |
Correct |
108 ms |
106028 KB |
Output is correct |
54 |
Correct |
109 ms |
105976 KB |
Output is correct |
55 |
Correct |
112 ms |
105772 KB |
Output is correct |
56 |
Correct |
118 ms |
105968 KB |
Output is correct |
57 |
Correct |
110 ms |
106296 KB |
Output is correct |
58 |
Correct |
122 ms |
105620 KB |
Output is correct |
59 |
Correct |
109 ms |
105380 KB |
Output is correct |
60 |
Correct |
111 ms |
105388 KB |
Output is correct |
61 |
Correct |
105 ms |
105292 KB |
Output is correct |
62 |
Correct |
119 ms |
104784 KB |
Output is correct |
63 |
Correct |
74 ms |
95544 KB |
Output is correct |
64 |
Correct |
86 ms |
95456 KB |
Output is correct |
65 |
Correct |
81 ms |
95420 KB |
Output is correct |
66 |
Correct |
76 ms |
95456 KB |
Output is correct |
67 |
Correct |
202 ms |
132656 KB |
Output is correct |
68 |
Correct |
216 ms |
131116 KB |
Output is correct |
69 |
Correct |
193 ms |
135400 KB |
Output is correct |
70 |
Correct |
79 ms |
95536 KB |
Output is correct |
71 |
Correct |
93 ms |
95568 KB |
Output is correct |
72 |
Correct |
194 ms |
120784 KB |
Output is correct |
73 |
Correct |
170 ms |
119404 KB |
Output is correct |
74 |
Correct |
94 ms |
95688 KB |
Output is correct |
75 |
Correct |
199 ms |
131672 KB |
Output is correct |
76 |
Correct |
78 ms |
95604 KB |
Output is correct |
77 |
Correct |
78 ms |
95324 KB |
Output is correct |
78 |
Incorrect |
70 ms |
95436 KB |
Output isn't correct |
79 |
Halted |
0 ms |
0 KB |
- |