QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874977#23. Bracketsandrejikus64 91ms4340kbC++142.0kb2025-01-28 22:53:022025-01-28 22:53:02

Judging History

This is the latest submission verdict.

  • [2025-01-28 22:53:02]
  • Judged
  • Verdict: 64
  • Time: 91ms
  • Memory: 4340kb
  • [2025-01-28 22:53:02]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 203;
const ll inf = 2e18;
vector<pair<int, char>> in[N], out[N];
ll d[N][N];

bool match(char a, char b) {
    if (a == '(') return (b == ')');
    if (a == '{') return (b == '}');
    if (a == '<') return (b == '>');
    if (a == '[') return (b == ']');
    return false;
}


void solve() {
   int n, m, s, t; cin >> n >> m >> s >> t;
   for (int i = 0; i <= n; i++)
        for (int j = 0; j <= n; j++)
            if (i != j) d[i][j] = inf;

   for (int i = 0; i < m; i++) {
        int u, v; char c;
        cin >> u >> v >> c;
        in[v].push_back({u, c});
        out[u].push_back({v, c});
   }
   priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> pq;
   for (int i = 1; i <= n; i++) pq.emplace(0, i, i);

   while (!pq.empty()) {
        auto [w, u, v] = pq.top(); pq.pop();
        if (d[u][v] != w) continue;
        for (auto [pu, c1] : in[u]) {
            for (auto [pv, c2] : out[v]) {
                if (match(c1, c2)) {
                    if (w+2 < d[pu][pv]) {
                        d[pu][pv] = w+2;
                        pq.emplace(d[pu][pv], pu, pv);
                    }
                }
            }
        }

        for (int x = 1; x <= n; x++) {
            for (int y = 1; y <= n; y++) {
                if (d[x][y] > d[x][u]+d[u][v]+d[v][y]) {
                    d[x][y] = d[x][u]+d[u][v]+d[v][y];
                    pq.emplace(d[x][y], x, y);
                }
            }
        }
   }

   cout << (d[s][t] == inf ? -1 : d[s][t]) << "\n";
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int t=1; //cin >> t;
	while (t--) {
        solve();
	}
}

详细

Subtask #1:

score: 16
Accepted

Test #1:

score: 16
Accepted
time: 1ms
memory: 3584kb

input:

10 50 6 8
1 6 {
5 10 <
7 10 [
9 6 [
8 1 (
4 8 <
1 1 <
10 3 [
5 7 [
2 1 (
8 2 <
1 4 [
10 6 <
8 9 >
3 5 <
2 8 <
10 4 {
9 6 (
3 2 [
7 2 [
9 10 ]
3 9 {
6 5 {
8 9 [
9 9 (
3 1 [
8 2 (
1 6 <
5 8 {
1 7 {
9 9 )
7 6 {
3 1 [
7 3 <
5 10 {
2 5 {
7 8 {
10 8 (
2 10 <
2 10 [
4 4 <
1 7 {
8 6 {
10 8 {
1 10 {
3 10 <
9...

output:

28

result:

ok single line: '28'

Test #2:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

10 12 1 10
4 5 [
9 4 [
4 7 {
2 10 [
1 3 (
8 9 >
10 10 }
10 6 ]
7 4 (
6 10 )
5 2 (
3 8 <

output:

16

result:

ok single line: '16'

Test #3:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

10 13 6 9
6 7 ]
6 5 )
10 6 (
6 1 >
8 6 [
6 2 }
6 6 <
2 10 }
5 8 )
4 6 {
1 4 >
3 9 ]
7 3 ]

output:

90

result:

ok single line: '90'

Test #4:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

10 50 4 2
1 9 >
6 6 [
8 9 )
7 1 >
5 4 >
1 6 {
2 7 [
4 7 >
6 8 }
4 6 )
5 3 <
3 1 <
1 9 {
2 3 )
5 5 }
1 1 >
7 10 }
7 10 [
7 6 (
5 2 {
3 1 >
3 6 )
5 3 (
9 8 ]
1 3 ]
7 4 )
10 2 }
8 2 ]
5 4 [
7 5 ]
10 6 {
3 10 >
6 8 )
7 3 )
3 2 ]
8 6 [
10 1 ]
3 7 )
10 4 >
8 4 ]
3 10 <
4 7 (
2 10 ]
5 7 <
9 5 }
1 10 }
6 3 ...

output:

10

result:

ok single line: '10'

Test #5:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

10 50 5 7
5 7 ]
2 10 (
5 2 >
2 9 }
5 2 )
2 9 [
5 4 {
6 3 )
2 10 (
9 10 >
8 9 [
5 1 (
8 9 }
10 3 )
2 3 <
10 3 )
9 6 <
10 3 ]
6 7 <
2 10 <
1 7 (
3 5 <
9 10 }
2 8 (
6 1 <
9 7 {
10 3 (
9 7 }
8 1 }
5 9 ]
9 3 }
10 4 (
9 4 (
2 4 <
2 1 >
9 7 <
9 7 }
2 8 }
9 7 )
2 1 <
5 8 ]
5 1 (
9 1 >
6 1 [
10 1 {
2 4 <
2 4...

output:

-1

result:

ok single line: '-1'

Test #6:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

8 11 1 6
8 5 (
1 7 {
4 6 )
1 1 [
3 6 >
7 2 <
1 6 (
2 3 }
5 6 )
6 4 ]
1 8 (

output:

-1

result:

ok single line: '-1'

Test #7:

score: 16
Accepted
time: 0ms
memory: 3584kb

input:

9 16 3 6
6 4 ]
3 8 [
6 3 (
8 1 [
2 2 )
9 9 )
5 5 )
1 7 [
7 4 (
4 4 )
7 3 [
4 5 ]
5 9 ]
9 2 ]
6 6 )
2 6 ]

output:

40

result:

ok single line: '40'

Test #8:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

10 50 6 7
2 1 {
8 10 (
6 2 <
8 4 ]
4 8 )
6 1 {
5 9 }
4 8 >
2 2 )
1 3 )
4 5 ]
1 5 )
4 6 [
6 2 }
2 8 >
7 3 [
2 1 >
2 7 (
8 7 {
6 4 ]
5 9 {
1 6 ]
2 1 ]
3 2 >
7 8 )
7 4 )
8 9 [
2 5 }
4 7 ]
7 6 }
4 5 )
8 2 ]
9 1 >
7 3 ]
7 2 [
2 6 >
7 8 >
6 6 >
9 5 <
10 2 (
7 6 [
5 1 )
5 3 )
5 2 ]
9 9 (
7 7 [
8 6 >
6 1 ]
...

output:

18

result:

ok single line: '18'

Test #9:

score: 16
Accepted
time: 1ms
memory: 3584kb

input:

9 13 1 5
7 4 }
9 2 >
3 9 <
4 9 [
6 7 {
7 4 <
6 6 }
2 6 )
6 6 [
8 3 (
5 6 <
1 8 [
4 5 ]

output:

8

result:

ok single line: '8'

Test #10:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

10 36 6 8
7 9 >
5 3 (
1 8 {
9 4 ]
7 3 (
10 7 ]
7 1 {
10 1 )
4 1 >
2 1 (
5 6 (
8 10 (
3 5 )
3 5 )
7 5 <
9 2 [
6 4 (
6 7 <
3 9 (
2 8 }
5 8 [
1 6 >
4 8 ]
6 1 ]
5 9 <
9 7 ]
5 1 <
10 4 <
4 6 {
4 7 }
8 5 <
2 3 <
9 2 <
3 3 [
4 4 <
1 4 {

output:

40

result:

ok single line: '40'

Test #11:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

10 50 7 1
9 9 ]
6 5 }
6 9 }
2 1 {
7 10 >
3 8 (
6 9 >
1 3 >
9 7 {
10 2 }
9 9 [
10 10 >
9 9 )
6 9 <
5 5 <
2 3 }
5 7 >
6 6 [
2 3 (
4 4 (
2 3 (
5 10 }
2 2 ]
4 4 [
10 1 [
9 5 <
1 3 [
6 5 }
6 5 (
2 1 ]
9 7 ]
3 3 [
3 4 )
10 1 [
8 8 }
5 10 [
2 2 ]
4 6 }
2 3 {
9 9 [
1 8 (
7 2 {
7 7 >
1 8 ]
8 8 (
10 10 )
1 3 ...

output:

22

result:

ok single line: '22'

Test #12:

score: 16
Accepted
time: 1ms
memory: 3584kb

input:

8 12 5 3
5 8 <
7 2 (
5 6 (
8 3 ]
5 1 {
4 5 }
2 4 [
1 3 >
6 3 }
5 7 {
5 3 )
3 3 ]

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 16
Accepted

Dependency #1:

100%
Accepted

Test #13:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

20 100 1 15
16 3 )
15 4 }
1 17 [
20 1 )
9 2 }
7 2 )
18 13 }
5 9 ]
12 18 ]
4 14 [
13 1 )
20 2 )
16 2 }
16 3 }
9 2 }
7 2 )
20 18 )
12 8 >
9 12 >
4 12 ]
12 16 >
4 17 ]
19 18 >
11 20 )
14 5 >
12 13 }
12 17 }
1 6 }
5 12 >
19 20 ]
15 5 >
1 20 <
6 8 }
17 6 ]
9 8 ]
6 6 )
20 1 <
8 18 >
9 1 >
1 18 >
16 5 )
2 ...

output:

-1

result:

ok single line: '-1'

Test #14:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

20 25 12 10
20 10 >
11 11 >
15 7 )
12 6 {
11 5 >
12 13 >
19 14 <
17 20 >
16 18 >
15 4 >
6 15 }
2 19 )
14 12 <
4 11 >
18 17 >
8 2 }
7 8 {
1 16 >
12 3 (
9 12 }
5 1 >
13 4 >
3 9 {
16 1 >
12 10 >

output:

80

result:

ok single line: '80'

Test #15:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

17 100 13 1
16 10 >
14 3 (
15 7 [
7 3 (
6 9 [
17 10 ]
14 6 <
10 15 ]
8 7 (
16 13 [
3 10 [
6 17 (
3 6 ]
17 12 <
6 11 >
2 13 }
9 7 <
2 10 {
4 8 <
17 14 [
15 13 )
10 12 <
2 15 }
7 1 >
5 7 [
16 16 {
13 17 >
8 13 }
2 10 }
14 14 <
6 13 (
13 8 >
3 8 >
6 9 ]
17 13 )
7 11 )
6 15 <
14 8 (
13 13 {
15 12 [
17 3...

output:

8

result:

ok single line: '8'

Test #16:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

20 99 5 6
2 3 {
3 13 {
8 6 (
11 3 [
16 12 <
20 14 <
12 11 {
18 18 <
2 10 <
3 11 [
9 13 {
16 9 (
2 19 [
12 7 (
16 7 (
7 3 [
2 20 [
13 13 {
4 20 )
3 5 (
10 9 {
8 14 {
20 18 (
4 13 <
15 15 <
6 11 {
6 10 {
17 13 {
20 14 ]
9 16 (
4 16 [
18 2 [
11 9 {
6 7 (
15 12 (
3 20 (
10 16 (
6 5 <
10 2 (
11 14 <
16 1...

output:

28

result:

ok single line: '28'

Test #17:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

20 95 11 13
18 10 <
13 7 (
18 10 <
2 2 )
8 16 >
16 3 <
15 4 (
11 9 >
16 9 )
7 1 <
10 6 {
19 5 (
2 3 ]
5 5 >
19 5 <
8 8 ]
15 10 <
9 19 [
13 12 ]
5 8 <
16 8 (
18 16 )
6 1 >
11 9 ]
3 8 [
19 12 [
5 3 [
18 18 [
4 8 >
8 12 [
9 4 }
10 20 <
8 7 >
19 5 {
10 18 ]
7 19 )
14 6 )
16 19 [
7 19 }
6 16 }
14 19 >
18...

output:

22

result:

ok single line: '22'

Test #18:

score: 16
Accepted
time: 0ms
memory: 3584kb

input:

1 0 1 1

output:

0

result:

ok single line: '0'

Test #19:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

20 23 12 11
2 4 )
17 9 }
14 10 >
19 12 <
20 8 ]
13 7 )
3 14 >
8 19 ]
6 17 }
10 18 >
15 20 ]
12 6 }
12 13 )
4 12 [
16 12 {
12 5 ]
18 16 >
1 11 }
9 1 }
5 15 ]
12 12 (
12 3 >
7 2 )

output:

1310

result:

ok single line: '1310'

Test #20:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

20 100 10 14
11 6 ]
16 19 >
2 16 >
11 3 <
19 16 }
6 18 }
11 4 >
14 6 ]
7 10 [
18 13 ]
19 11 }
1 17 ]
13 5 >
4 9 ]
10 20 )
14 3 >
11 9 )
3 12 )
8 13 {
11 12 >
20 18 )
2 20 >
10 12 )
8 12 >
13 7 {
20 19 )
10 16 )
17 16 ]
9 6 ]
16 17 }
2 3 )
13 10 }
18 11 )
17 10 ]
8 7 )
20 1 }
3 20 ]
10 18 >
16 15 ]
5...

output:

24

result:

ok single line: '24'

Test #21:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

20 93 14 18
20 19 }
19 18 <
2 10 (
17 18 [
10 7 >
10 17 {
3 12 <
15 1 }
17 8 {
5 3 >
12 3 {
8 5 <
1 10 (
13 5 (
10 19 ]
2 6 >
7 2 )
12 12 }
20 1 {
12 20 )
19 13 >
13 2 [
8 1 {
16 6 <
8 16 )
6 14 (
7 10 }
10 11 <
19 14 ]
14 10 ]
17 16 <
9 12 ]
20 7 }
18 16 {
18 9 )
10 4 [
5 9 ]
9 12 (
20 13 {
6 10 (
...

output:

22

result:

ok single line: '22'

Test #22:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

20 97 3 4
20 16 >
9 20 >
20 15 [
2 9 {
14 11 }
6 9 }
14 3 <
11 4 (
18 16 ]
10 17 )
11 3 )
2 18 [
12 2 >
6 14 <
16 10 {
17 9 (
11 17 }
19 11 )
8 8 {
16 17 }
9 12 {
8 19 )
2 11 >
20 16 <
13 7 >
9 17 }
6 14 {
3 7 }
6 13 )
18 14 (
12 8 [
17 5 <
15 10 }
12 17 {
8 2 <
4 13 {
4 14 [
2 11 <
7 19 {
18 16 >
2...

output:

16

result:

ok single line: '16'

Test #23:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

20 24 20 3
9 20 {
8 8 }
4 18 (
6 19 (
14 2 {
3 3 }
3 8 )
13 9 {
18 10 {
16 6 {
7 17 {
20 1 {
8 2 )
19 12 {
5 14 {
17 16 {
5 4 {
10 11 {
15 13 (
2 3 )
12 5 {
1 7 (
11 15 {
2 2 }

output:

84

result:

ok single line: '84'

Test #24:

score: 16
Accepted
time: 0ms
memory: 3584kb

input:

20 100 19 6
2 2 ]
1 19 >
9 15 {
13 16 >
7 7 (
1 2 [
6 6 <
9 5 [
18 18 <
3 3 >
19 10 >
15 12 ]
14 13 [
14 13 <
18 7 }
8 4 >
18 18 >
12 12 (
3 14 (
18 7 (
2 2 (
12 20 [
16 16 {
11 9 )
8 4 )
6 13 >
13 17 >
14 6 {
14 14 }
12 12 (
10 7 <
2 19 ]
14 13 )
4 4 <
1 1 ]
20 6 ]
9 15 (
8 11 {
2 18 [
13 17 )
12 3...

output:

26

result:

ok single line: '26'

Subtask #3:

score: 16
Accepted

Dependency #2:

100%
Accepted

Test #25:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

44 94 23 7
20 12 (
33 13 {
41 8 )
16 38 )
27 18 [
7 16 )
22 13 )
26 26 [
42 42 ]
9 9 ]
31 31 ]
34 34 ]
5 31 )
28 28 [
40 23 (
35 35 ]
29 22 )
39 27 (
14 14 ]
14 6 >
39 35 )
44 44 [
22 26 {
7 7 ]
21 21 ]
38 30 )
25 28 (
5 5 ]
14 21 )
44 3 (
36 32 (
23 2 (
24 24 [
2 2 [
36 36 [
12 12 [
10 10 ]
37 6 (
...

output:

232

result:

ok single line: '232'

Test #26:

score: 16
Accepted
time: 6ms
memory: 3968kb

input:

50 280 13 25
26 25 (
18 30 )
28 8 >
43 33 }
34 2 [
2 33 }
35 5 }
21 41 >
1 31 [
50 18 <
36 5 }
31 33 <
37 14 }
50 39 }
14 41 >
27 44 >
16 7 }
50 44 {
32 14 <
13 8 >
1 47 <
18 16 [
20 36 >
18 50 >
7 50 <
30 15 [
13 15 >
15 22 [
36 10 }
16 36 ]
22 33 )
34 30 (
16 15 >
49 48 >
49 32 [
35 30 [
2 43 )
30...

output:

18

result:

ok single line: '18'

Test #27:

score: 16
Accepted
time: 7ms
memory: 3712kb

input:

50 2000 25 13
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
13 9 )
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
27 27 [
32 32 [
27 27 [
27 27 [
27 27 [
27 27 [...

output:

9942

result:

ok single line: '9942'

Test #28:

score: 16
Accepted
time: 2ms
memory: 3840kb

input:

50 58 48 49
26 47 [
8 8 <
5 12 )
14 43 >
32 31 {
30 21 >
48 8 (
29 5 )
16 33 (
8 45 [
31 39 }
37 2 }
44 41 {
12 49 )
10 19 ]
15 42 [
15 14 >
13 44 (
43 45 (
14 38 (
50 38 )
31 36 >
47 17 ]
36 30 <
43 35 <
43 16 [
39 43 ]
41 42 }
38 26 )
45 48 )
47 13 {
1 13 (
16 41 >
19 50 (
45 1 ]
1 37 {
11 32 <
3 ...

output:

14

result:

ok single line: '14'

Test #29:

score: 16
Accepted
time: 7ms
memory: 3840kb

input:

50 610 7 16
7 30 )
8 48 (
18 13 }
39 10 ]
25 29 <
6 40 {
24 42 [
43 2 )
27 45 (
18 14 <
27 24 }
7 4 ]
28 35 )
10 26 (
7 40 (
48 6 ]
47 23 }
49 50 }
49 25 ]
29 25 }
24 38 >
47 35 ]
16 5 [
22 40 }
30 17 [
19 34 >
21 27 >
35 42 {
38 43 }
31 30 <
14 34 [
23 32 {
24 42 )
36 1 (
33 50 ]
33 1 }
5 43 (
28 4...

output:

-1

result:

ok single line: '-1'

Test #30:

score: 16
Accepted
time: 11ms
memory: 4096kb

input:

50 2000 22 12
15 24 [
43 14 )
17 3 {
20 29 )
15 40 (
4 14 {
40 36 ]
43 24 >
39 39 >
44 23 <
40 34 >
23 23 <
32 21 >
49 13 ]
49 17 )
46 8 ]
17 46 ]
33 37 {
4 31 }
36 11 ]
46 8 <
16 16 >
15 29 ]
16 31 )
46 32 >
31 34 [
44 28 }
47 6 >
25 25 }
19 33 >
9 50 >
15 31 <
23 9 ]
36 36 {
15 31 <
34 11 (
42 6 (...

output:

10

result:

ok single line: '10'

Test #31:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

50 76 43 19
35 18 }
9 29 }
42 37 }
24 49 )
50 8 (
21 21 {
7 9 )
36 38 (
28 28 {
46 21 [
11 25 )
47 10 )
28 5 (
40 28 [
31 31 ]
30 34 )
11 11 ]
19 19 ]
17 2 )
38 48 [
18 6 )
3 4 (
7 7 ]
4 36 [
29 35 )
18 18 ]
32 32 ]
2 31 }
50 50 {
22 19 }
12 13 )
10 30 }
29 29 ]
45 16 [
26 24 }
13 27 }
48 46 (
27 27...

output:

848

result:

ok single line: '848'

Test #32:

score: 16
Accepted
time: 0ms
memory: 3712kb

input:

50 100 11 17
50 35 {
46 8 <
4 1 }
4 9 (
30 4 {
5 5 {
39 28 {
3 22 {
48 40 {
26 28 {
4 39 {
37 46 {
35 36 {
38 25 (
28 23 [
27 6 (
30 46 <
16 19 (
30 16 {
35 23 <
18 30 <
21 38 <
28 31 [
36 22 (
13 36 (
22 49 (
38 44 (
6 28 <
43 16 {
17 29 [
17 1 ]
28 22 <
27 46 (
31 27 <
32 8 <
27 10 [
2 25 <
24 2 {...

output:

40

result:

ok single line: '40'

Test #33:

score: 16
Accepted
time: 5ms
memory: 3968kb

input:

50 204 36 14
20 46 <
31 33 }
9 8 ]
21 17 [
6 25 ]
25 45 )
21 38 )
8 18 )
44 41 >
28 38 {
46 9 )
36 39 ]
31 3 }
44 19 >
28 18 }
43 49 <
44 34 >
47 25 )
19 19 )
41 19 ]
35 44 <
30 36 (
45 4 >
29 10 <
20 31 )
9 6 )
2 16 )
25 29 ]
7 43 ]
1 49 <
16 26 {
26 41 [
10 18 )
42 12 [
26 4 >
42 33 {
31 16 <
40 1...

output:

12

result:

ok single line: '12'

Test #34:

score: 16
Accepted
time: 0ms
memory: 3840kb

input:

50 50 21 17
2 33 )
26 24 )
21 21 (
43 42 )
13 4 )
35 8 )
25 41 )
1 19 )
3 39 )
7 23 )
10 25 )
20 3 )
37 1 )
8 27 )
27 2 )
15 35 )
29 28 )
30 36 )
31 47 )
34 15 )
40 48 )
41 22 )
44 26 )
18 7 )
49 32 )
19 12 )
5 37 )
16 13 )
39 9 )
38 11 )
22 20 )
46 5 )
24 45 )
12 17 )
11 40 )
21 30 )
36 10 )
28 6 )...

output:

98

result:

ok single line: '98'

Test #35:

score: 16
Accepted
time: 10ms
memory: 3968kb

input:

50 2000 21 44
2 19 [
27 11 [
1 29 )
48 47 <
8 44 (
25 41 (
15 16 [
36 5 [
37 50 [
50 15 ]
21 22 <
12 26 )
13 24 [
47 20 (
7 7 {
15 26 )
23 14 ]
1 14 [
34 3 >
29 36 >
30 6 )
10 48 >
41 39 ]
44 42 (
8 7 )
25 22 ]
11 24 }
41 45 )
20 37 )
37 12 <
2 17 >
10 10 <
39 23 ]
17 4 >
4 41 <
19 27 }
47 16 }
6 30...

output:

2

result:

ok single line: '2'

Test #36:

score: 16
Accepted
time: 8ms
memory: 4096kb

input:

50 666 20 18
49 49 ]
40 40 (
1 19 (
34 5 )
2 2 }
20 20 }
42 33 [
18 25 {
34 34 [
17 17 }
37 11 <
7 7 <
46 8 (
32 29 ]
40 40 (
49 49 (
22 26 {
14 15 {
6 31 {
41 5 >
4 29 [
48 35 <
6 31 >
17 17 {
28 22 }
37 48 }
18 25 (
23 19 (
5 5 <
35 35 )
23 19 {
8 8 <
26 26 <
5 40 )
38 38 <
16 28 [
22 26 }
6 6 (
8...

output:

30

result:

ok single line: '30'

Subtask #4:

score: 16
Accepted

Dependency #3:

100%
Accepted

Test #37:

score: 16
Accepted
time: 20ms
memory: 3840kb

input:

100 143 52 5
5 24 >
62 35 [
78 60 )
79 76 ]
6 46 [
66 50 )
19 43 )
43 65 )
21 53 {
75 74 )
37 37 (
40 40 (
13 80 )
9 39 )
63 63 (
86 68 [
50 90 )
7 31 )
93 16 [
76 17 )
8 51 )
70 98 [
15 54 [
25 87 [
54 64 [
57 33 [
41 4 [
71 22 <
51 34 )
12 5 ]
23 32 [
85 85 (
74 14 ]
90 18 )
85 36 [
20 94 <
52 45 ...

output:

115038

result:

ok single line: '115038'

Test #38:

score: 16
Accepted
time: 91ms
memory: 4192kb

input:

100 2000 91 69
73 95 ]
98 25 (
25 82 >
40 50 (
74 52 >
86 91 {
2 27 }
69 13 )
38 48 {
10 4 ]
48 49 (
35 67 )
82 82 [
30 70 >
12 22 ]
41 82 }
88 64 (
50 99 [
26 47 >
81 49 }
3 34 <
77 48 [
11 34 ]
29 24 >
60 23 )
60 50 {
75 99 (
53 81 (
2 40 <
64 80 {
4 44 ]
33 40 >
15 70 ]
54 82 )
71 62 {
76 68 }
68...

output:

4

result:

ok single line: '4'

Test #39:

score: 16
Accepted
time: 6ms
memory: 3968kb

input:

100 500 63 90
53 52 [
70 56 {
2 14 (
85 32 [
99 81 [
18 51 {
100 61 {
86 56 [
86 5 {
23 9 [
24 86 (
8 12 {
51 5 (
30 18 (
90 13 )
96 72 (
68 9 [
49 92 {
86 95 {
72 15 [
58 87 [
92 7 {
93 63 [
54 59 {
40 75 {
99 60 (
6 46 {
36 77 {
36 4 [
50 73 <
56 83 [
13 71 >
26 82 {
42 48 (
5 59 {
12 24 (
44 68 [...

output:

28

result:

ok single line: '28'

Test #40:

score: 16
Accepted
time: 2ms
memory: 3968kb

input:

100 200 37 48
56 12 <
32 81 {
47 86 (
74 24 )
71 13 ]
89 5 [
23 92 [
17 24 )
69 30 ]
29 86 (
13 33 ]
14 4 }
26 56 }
75 33 (
20 31 (
100 81 }
30 60 {
94 86 ]
59 68 }
87 38 ]
57 69 [
6 48 }
33 38 <
45 67 [
20 92 }
47 40 [
89 4 {
4 41 <
77 66 )
40 41 (
92 68 {
100 85 [
64 51 ]
98 12 <
6 77 [
92 97 )
29...

output:

10

result:

ok single line: '10'

Test #41:

score: 16
Accepted
time: 90ms
memory: 4184kb

input:

100 2000 13 66
78 50 }
73 51 )
83 80 [
12 42 ]
77 30 (
13 51 {
51 89 {
82 35 <
80 68 [
40 51 {
28 5 >
99 89 ]
85 4 }
30 32 }
90 27 [
93 76 }
41 61 {
30 56 )
82 52 )
91 61 {
55 23 >
13 66 >
30 18 >
79 46 {
83 44 }
76 73 )
61 66 (
36 28 [
64 26 {
89 97 [
47 49 [
57 87 {
51 3 )
58 67 >
97 17 [
14 47 (
...

output:

4

result:

ok single line: '4'

Test #42:

score: 16
Accepted
time: 1ms
memory: 3840kb

input:

100 300 38 99
31 31 {
76 9 [
66 66 {
11 61 {
77 34 ]
94 29 ]
81 85 (
22 95 <
77 77 }
63 42 (
18 17 )
45 68 ]
74 50 <
71 71 <
85 85 (
64 89 <
87 74 >
78 78 >
78 15 ]
30 30 ]
65 65 >
36 36 }
97 55 >
20 58 }
23 23 {
72 72 )
54 60 ]
70 70 )
28 23 {
65 65 [
46 46 )
29 29 (
28 28 }
63 42 ]
8 8 [
83 30 (
1...

output:

18

result:

ok single line: '18'

Test #43:

score: 16
Accepted
time: 3ms
memory: 3712kb

input:

98 120 54 43
7 79 >
35 21 {
86 35 {
3 65 {
25 16 <
38 39 {
16 17 <
17 45 [
69 62 }
43 32 }
47 87 <
75 31 <
71 76 ]
72 95 (
54 22 <
76 71 )
59 34 [
59 71 [
10 51 )
80 70 {
91 7 >
30 28 <
31 82 [
97 27 <
39 20 {
95 67 {
30 34 )
45 73 <
55 83 {
4 58 {
83 84 {
6 25 <
52 60 <
78 50 {
65 5 {
43 63 >
29 78...

output:

952

result:

ok single line: '952'

Test #44:

score: 16
Accepted
time: 11ms
memory: 3840kb

input:

99 127 14 52
79 73 [
70 67 )
30 36 [
6 77 <
58 58 (
71 71 (
14 4 >
55 88 [
98 7 }
44 41 [
22 42 [
12 30 [
26 94 >
3 16 [
6 1 )
87 34 {
94 32 >
41 10 {
46 46 (
36 58 {
15 62 }
53 92 ]
63 20 [
21 69 >
18 11 {
76 92 }
4 23 >
66 54 )
19 66 ]
95 44 [
73 47 {
80 46 {
37 37 (
53 35 )
86 86 (
28 72 [
78 78 ...

output:

3488

result:

ok single line: '3488'

Test #45:

score: 16
Accepted
time: 88ms
memory: 4192kb

input:

100 2000 90 84
35 20 >
21 67 [
55 75 {
43 92 ]
58 61 [
61 17 <
77 67 {
83 33 ]
74 39 >
26 52 {
46 37 (
19 99 }
32 45 ]
36 85 (
35 57 )
44 15 }
89 81 )
10 79 (
33 77 ]
30 13 )
71 43 {
89 87 (
28 7 (
97 29 [
96 69 }
4 92 <
97 48 [
19 15 )
35 22 {
76 73 )
97 36 <
59 81 (
45 36 >
6 50 (
55 90 )
23 21 }
...

output:

4

result:

ok single line: '4'

Test #46:

score: 16
Accepted
time: 91ms
memory: 4188kb

input:

100 2000 40 14
32 38 ]
62 62 }
33 75 <
2 3 )
11 95 [
31 23 }
20 45 {
73 64 }
15 52 (
49 79 <
49 75 [
21 98 {
74 78 [
47 85 >
54 92 <
94 100 {
76 10 {
10 39 ]
20 38 ]
82 62 ]
29 94 )
15 80 {
51 62 [
60 21 {
85 52 [
69 70 {
89 32 (
79 67 )
22 97 {
30 7 }
56 52 }
19 63 [
31 8 <
78 95 }
57 91 (
87 23 <
...

output:

6

result:

ok single line: '6'

Test #47:

score: 16
Accepted
time: 14ms
memory: 3968kb

input:

100 553 80 4
90 7 <
2 47 <
56 78 {
90 89 {
46 44 >
83 28 (
58 99 [
27 38 {
98 58 [
73 85 [
45 12 [
44 7 )
13 97 {
61 93 [
89 12 [
37 88 <
48 48 <
9 42 {
20 54 <
91 64 (
51 44 }
6 38 (
69 2 <
59 93 {
34 64 {
81 70 {
93 62 [
62 8 [
89 69 {
29 78 [
51 85 [
46 98 (
25 31 [
65 44 >
74 12 {
98 95 <
45 42 ...

output:

20

result:

ok single line: '20'

Test #48:

score: 16
Accepted
time: 91ms
memory: 4340kb

input:

100 2000 36 87
86 100 (
53 31 [
91 91 ]
63 19 [
52 16 {
41 35 [
2 1 [
50 42 }
5 5 {
94 3 {
80 77 [
10 10 >
85 53 (
36 50 )
59 81 [
99 99 <
79 79 [
96 96 ]
59 81 {
86 69 <
100 69 <
69 69 [
30 30 >
63 77 )
78 90 ]
23 65 }
54 65 [
16 47 <
19 19 {
99 65 >
91 92 >
69 63 <
22 55 {
21 100 }
76 4 <
60 99 }
...

output:

36

result:

ok single line: '36'

Test #49:

score: 16
Accepted
time: 1ms
memory: 3712kb

input:

79 80 77 34
20 36 ]
42 37 ]
19 26 ]
11 74 [
46 33 ]
10 5 ]
38 62 ]
47 19 ]
49 54 ]
53 50 ]
40 7 [
33 30 ]
56 10 ]
27 42 ]
2 11 [
18 63 ]
8 51 >
41 43 ]
65 68 ]
70 55 [
68 24 ]
61 39 ]
66 67 ]
74 35 [
69 65 ]
12 78 [
31 69 ]
55 52 [
51 31 ]
35 75 [
71 53 ]
13 28 [
40 8 <
64 9 ]
30 79 ]
62 76 ]
5 22 ]...

output:

-1

result:

ok single line: '-1'

Subtask #5:

score: 0
Time Limit Exceeded

Test #50:

score: 0
Time Limit Exceeded

input:

200 2000 1 200
135 138 {
126 129 [
167 169 >
195 198 ]
187 188 (
66 70 )
61 65 <
13 14 {
193 196 [
188 190 )
4 5 <
137 140 ]
32 34 ]
87 91 (
103 107 )
182 186 >
168 169 <
101 104 (
193 196 <
36 37 }
109 110 (
141 145 [
33 34 <
192 194 ]
34 38 <
176 178 ]
145 146 <
90 94 [
152 156 ]
81 84 }
9 13 >
83...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

0%