QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595565#6340. TourismMispertion#31 390ms71656kbC++234.5kb2024-09-28 14:00:582024-09-28 14:00:59

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 14:00:59]
  • 评测
  • 测评结果:31
  • 用时:390ms
  • 内存:71656kb
  • [2024-09-28 14:00:58]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"

const ld PI = 3.1415926535;
const int N = 5e5 + 1;
const int M = 50 + 1;
const int mod = 1e9+7;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
const int P = 31;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) { 
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

struct fenwick{
    int f[N];
    
    void add(int i, int x){
        for(; i < N; i = (i | (i + 1)))
            f[i] += x;
    }
    
    int get(int r){
        int ret = 0;
        for(; r >= 0; r = (r & (r + 1)) - 1)
            ret += f[r];
        return ret;
    }

    int get(int l, int r){
        return get(r) - get(l - 1);
    }
};

int n, m, q, c[N], sz[N], d[N], h[N], cmp[N], par[N], cur;
vector<int> g[N];
set<pair<pii, int>> st[N];
vector<int> sp[N];
fenwick f;

void dfs(int v, int p){
    par[v] = p;
    sz[v] = 1;
    for(auto u : g[v]){
        if(u == p) continue;
        d[u] = d[v] + 1;
        dfs(u, v);
        sz[v] += sz[u];
    }
}

void dfs1(int v, int r){
    h[v] = r;
    sp[r].pb(v);
    int mxu = -1;
    for(auto u : g[v]){
        if(u == par[v]) continue;
        if(mxu == -1 || sz[mxu] < sz[u])
            mxu = u;
    }
    if(mxu != -1){
        for(auto u : g[v]){
            if(u == par[v]) continue;
            dfs1(u, (u == mxu ? r : u));
        }
    }
}

void upd(int i, int l, int r, int x){
    auto s = st[i].upper_bound({{l, -1}, -1});
    vector<pair<pii, int>> td = {};
    for(auto it = s; it != st[i].end(); it++){
        if(it->F.S > r) break;
        f.add(it->S, -(it->F.S - it->F.F + 1));
        td.pb(*it);
    }
    for(auto e : td)
        st[i].erase(e);
    s = st[i].upper_bound({{l, -1}, -1});
    if(s != st[i].end()){
        if(s->F.F <= r){
            f.add(s->S, -(r - s->F.F + 1));
            auto par = *s;
            st[i].erase(s);
            st[i].insert({{r + 1, par.F.S}, par.S});
        }
    }
    s = st[i].upper_bound({{l, -1}, -1});
    if(s != st[i].begin()){
        s--;
        if(l <= s->F.S){
            f.add(s->S, -(s->F.S - l + 1));
            auto par = *s;
            st[i].erase(s);
            st[i].insert({{par.F.F, l - 1}, par.S});
        }
    }
    f.add(x, r - l + 1);
    st[i].insert({{l, r}, x});
}

void upd1(int u, int v, int x){
    while(true){
        if(h[v] == h[u]){
            if(d[u] > d[v])
                swap(u, v);
            int l = lower_bound(all(sp[h[v]]), u) - sp[h[v]].begin();
            int r = lower_bound(all(sp[h[v]]), v) - sp[h[v]].begin();
            upd(h[v], l, r, x);
            break;
        }
        if(d[h[v]] < d[h[u]])
            swap(u, v);
        int r = lower_bound(all(sp[h[v]]), v) - sp[h[v]].begin();
        upd(h[v], 0, r, x);
        v = par[h[v]];
    }
}

vector<pii> rs[N];
int ans[N];

void solve(){
    cin >> n >> m >> q;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[v].pb(u);
        g[u].pb(v);
    }
    for(int i = 1; i <= m; i++){
        cin >> c[i];
    }
    for(int i = 1; i <= q; i++){
        int l, r;
        cin >> l >> r;
        rs[r].pb({l, i});
    }
    dfs(1, 0);
    dfs1(1, 1);
    for(int r = 1; r <= m; r++){
        if(r != 1){
            upd1(c[r - 1], c[r], r - 1);
        }
        for(auto e : rs[r]){
            if(e.F == r){
                ans[e.S] = 1;
                continue;
            }
            ans[e.S] = f.get(e.F, m);
        }
    }
    for(int i = 1; i <= q; i++){
        cout << ans[i] << '\n';
    }
}   

signed main() {
    mispertion;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 40772kb

input:

166 249 224
158 52
52 82
158 36
117 158
119 117
5 82
158 18
22 36
82 143
105 36
22 152
36 92
117 2
123 158
5 134
119 89
31 119
92 48
105 149
149 17
108 31
134 50
3 52
63 158
3 51
42 22
17 10
103 158
50 122
92 85
50 78
117 159
36 20
143 115
158 83
20 4
142 22
23 3
96 10
19 134
8 10
151 92
65 108
89 5...

output:

65
110
115
109
124
150
104
34
135
134
94
106
86
111
23
130
96
86
95
54
113
142
67
36
3
41
86
117
51
131
70
142
80
73
96
91
121
103
31
104
137
85
93
130
78
137
129
91
33
73
115
132
67
54
101
112
31
90
138
50
73
144
91
103
25
136
119
127
38
98
131
117
142
26
46
118
150
34
114
76
137
114
1
118
149
95
1...

result:

wrong answer 1st numbers differ - expected: '67', found: '65'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 7
Accepted

Test #56:

score: 7
Accepted
time: 85ms
memory: 56060kb

input:

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

output:

55319
55319
55313
55306
55319
53676
55320
55301
55319
55319
55268
55319
55318
55320
55311
55311
55319
55275
55301
55319
55319
55317
55320
55319
55319
55318
55295
55318
55319
55319
55319
55248
55319
55320
55319
55319
55319
55319
55319
55319
55320
55301
55319
55186
55204
55320
55319
55319
55297
55318
...

result:

ok 75523 numbers

Test #57:

score: 7
Accepted
time: 71ms
memory: 60692kb

input:

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

output:

80782
80805
80805
80769
80805
80805
80805
80791
80805
80782
80805
80805
80783
80805
80802
80805
80334
80791
80777
80805
80805
80802
80805
80805
80805
80805
80805
80758
80805
80789
80805
80790
80805
80805
80805
80805
80781
80777
80805
80805
80805
80805
80802
80805
80805
80805
80805
80777
80777
80805
...

result:

ok 65576 numbers

Test #58:

score: 7
Accepted
time: 82ms
memory: 60224kb

input:

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

output:

91904
91883
91878
91896
91897
91902
91902
91901
91748
91902
91904
91904
91901
91904
91896
91904
91896
91901
91901
91904
91900
91886
91902
91904
91894
91902
91853
91885
91893
91893
91902
91900
91902
91886
91902
91904
91416
91904
91901
91904
91904
91902
91904
91904
91902
91904
91828
91809
91904
91875
...

result:

ok 54619 numbers

Test #59:

score: 7
Accepted
time: 124ms
memory: 63012kb

input:

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

output:

99999
99954
99991
99993
99986
99942
99993
99986
99994
99993
99993
99993
99989
99986
99999
99991
99994
99956
99999
99989
99991
99999
99991
99981
99973
99993
99999
99983
99986
99991
99986
99999
99988
99954
99983
99999
99983
99993
99999
99993
99986
99991
99999
99999
99999
99991
99993
99993
99837
99990
...

result:

ok 100000 numbers

Test #60:

score: 7
Accepted
time: 118ms
memory: 63360kb

input:

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

output:

100000
99997
99998
99992
99992
99970
99996
99981
99981
99997
99982
99981
99990
99973
99963
99997
99997
99537
99997
99990
99997
99997
99990
100000
99997
99987
99943
100000
99981
99981
99996
99960
99998
99997
100000
99991
99754
99961
99960
99990
99990
100000
99997
99963
99981
99935
99991
100000
99997
...

result:

ok 100000 numbers

Test #61:

score: 7
Accepted
time: 109ms
memory: 67512kb

input:

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

output:

99996
99998
99998
99998
99994
99915
99996
99972
99996
99998
99998
99837
99996
99998
99996
99994
99989
99942
99998
99603
99998
99972
99981
99915
99463
99994
99994
99994
99996
99969
99972
99989
99998
99989
99998
99603
99843
99959
99998
99998
99998
99996
99998
99998
99996
99998
99996
99998
99994
99998
...

result:

ok 100000 numbers

Test #62:

score: 7
Accepted
time: 111ms
memory: 67476kb

input:

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

output:

99997
99994
99951
99998
99994
99998
99990
100000
100000
100000
99996
100000
99994
99980
99998
99990
99967
99994
100000
100000
99998
99997
99994
99991
100000
100000
100000
99970
100000
99997
99998
100000
99998
99994
99997
99981
99994
99982
99997
100000
100000
99997
99998
99997
100000
100000
99997
100...

result:

ok 100000 numbers

Test #63:

score: 7
Accepted
time: 111ms
memory: 67672kb

input:

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

output:

99995
99990
99997
99999
99999
99999
99999
99999
99997
99971
99969
99999
99999
99997
99999
99999
99999
99990
99999
99999
99990
99999
99997
99999
99999
99999
99999
99999
99999
99894
99999
99913
99999
99999
99973
99999
99986
99999
99999
99999
99997
99999
99990
99989
99990
99999
99999
99999
99997
99990
...

result:

ok 100000 numbers

Test #64:

score: 7
Accepted
time: 97ms
memory: 60564kb

input:

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

output:

99720
99788
99790
99720
99916
99714
99738
99834
99815
99707
99944
99584
99856
99930
99916
99856
99982
99796
99627
99754
99782
99790
99788
99848
99627
99982
99834
99834
99751
99944
99728
99751
99817
99944
99796
99720
99831
99916
99831
99728
99707
99627
99859
99668
99848
99771
99710
99710
99728
99838
...

result:

ok 100000 numbers

Test #65:

score: 7
Accepted
time: 87ms
memory: 63164kb

input:

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

output:

99649
99852
99852
99852
99632
99758
99761
99820
99730
99750
99887
99783
99721
99865
99802
99867
99798
99811
99553
99691
99852
99750
99787
99774
99948
99774
99695
99811
99649
99811
99908
99975
99806
99761
99760
99820
99862
99806
99903
99798
99783
99691
99811
99903
99908
99865
99811
99632
99750
99948
...

result:

ok 100000 numbers

Test #66:

score: 7
Accepted
time: 95ms
memory: 60792kb

input:

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

output:

99753
99961
99806
99756
99720
99900
99749
99823
99720
99846
99756
99602
99950
99749
99841
99818
99558
99792
99762
99900
99719
99750
99756
99856
99756
99950
99728
99934
99884
99660
99706
99762
99884
99977
99793
99860
99756
99602
99770
99833
99764
99841
99558
99937
99756
99950
99950
99756
99910
99729
...

result:

ok 100000 numbers

Test #67:

score: 7
Accepted
time: 36ms
memory: 62716kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #68:

score: 7
Accepted
time: 104ms
memory: 67668kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Subtask #4:

score: 0
Wrong Answer

Test #69:

score: 0
Wrong Answer
time: 112ms
memory: 49396kb

input:

54738 54525 1797
45211 4527
4527 43609
4527 19876
16325 43609
32183 4527
16325 32579
43609 25554
32183 38972
45211 53953
16325 19810
10881 19810
45211 12698
27967 19810
25554 46338
51894 45211
25388 16325
512 25554
43609 7820
10206 512
30021 32183
48647 43609
46338 44138
16766 7820
10023 53953
19810...

output:

531
543
389
432
561
492
430
545
325
440
492
580
456
450
420
514
343
579
389
546
570
506
462
494
589
398
501
441
490
404
348
320
434
492
395
502
468
472
433
473
566
435
575
591
486
489
470
413
592
502
386
416
375
475
552
601
549
529
317
471
522
390
342
347
431
404
402
637
480
502
402
419
574
490
385
...

result:

wrong answer 1st numbers differ - expected: '276', found: '531'

Subtask #5:

score: 24
Accepted

Test #102:

score: 24
Accepted
time: 277ms
memory: 63272kb

input:

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

output:

42788
7820
39914
18090
47411
43990
2171
29300
18235
16451
44208
47526
32163
44460
32385
30155
45741
45708
47396
43518
30989
19208
13902
35077
49210
21200
43577
32110
19690
35461
45079
11601
42233
16862
23259
44558
41924
39465
34626
41081
32139
34482
41166
24623
11638
18786
29659
38064
42423
42321
30...

result:

ok 95687 numbers

Test #103:

score: 24
Accepted
time: 300ms
memory: 55556kb

input:

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

output:

26124
11696
34672
19906
37517
39745
12092
11803
38936
29481
39777
42062
22087
43080
42468
22618
42584
42512
36052
48395
44563
29063
20611
42203
40753
37002
24991
38717
37467
43935
36308
37416
43842
39169
44996
35657
38159
30030
41535
34488
37655
50046
46898
42657
45573
4308
15509
41852
28225
32898
3...

result:

ok 89370 numbers

Test #104:

score: 24
Accepted
time: 330ms
memory: 58820kb

input:

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

output:

54950
43189
36772
1311
65352
65239
39742
60625
5657
51176
12141
22845
42904
46862
12604
38455
45384
26962
63267
28904
9995
50936
39499
48890
47780
7253
6239
49271
59029
46282
27940
57496
64917
52909
58560
27947
46253
21818
59417
63544
21645
37364
26764
23249
66794
50332
51190
44172
68809
62291
46510...

result:

ok 96158 numbers

Test #105:

score: 24
Accepted
time: 335ms
memory: 63684kb

input:

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

output:

74296
48517
45111
49478
42663
30316
66980
14003
52373
69355
26205
22241
70123
62132
25494
49459
17717
51008
30285
38307
61890
49679
39923
21693
19328
73265
26327
77090
54503
74185
49855
27162
51570
35838
65915
75805
44534
68679
45700
9883
73608
21808
60186
5320
43240
42021
55300
38369
51151
63595
73...

result:

ok 100000 numbers

Test #106:

score: 24
Accepted
time: 345ms
memory: 63940kb

input:

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

output:

55661
72881
55021
58078
53349
21715
54142
73477
55470
56603
40428
59731
54626
8400
56046
17766
66014
48806
76195
61741
49472
66302
55213
40434
58123
46091
46564
60096
73852
67311
77958
38297
54985
40428
23638
29758
15211
31168
52671
58116
56280
67887
68408
37271
74504
52906
24333
39868
15906
62095
1...

result:

ok 100000 numbers

Test #107:

score: 24
Accepted
time: 342ms
memory: 63540kb

input:

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

output:

49384
72701
65618
43104
29539
20835
59080
59167
56906
20578
46819
13802
50034
47888
68226
69683
53386
58689
3005
68357
70057
42532
29448
63486
59387
75767
1484
50118
7531
59768
64142
33124
58482
70372
21619
5524
37882
49407
57595
67194
8814
23826
74496
45761
8423
63268
52487
63160
58909
53162
65003
...

result:

ok 100000 numbers

Test #108:

score: 24
Accepted
time: 338ms
memory: 63648kb

input:

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

output:

38465
43388
71697
56061
6291
40224
57457
67627
68790
34583
73389
43063
39974
73144
52951
58669
70864
15981
45044
23527
30202
26791
60615
60846
50771
69093
32598
52346
53692
33355
42582
70057
12128
52963
31023
36955
48359
39535
6049
31335
74831
64311
32046
45695
67030
59949
69438
71994
5359
26311
621...

result:

ok 100000 numbers

Test #109:

score: 24
Accepted
time: 376ms
memory: 63348kb

input:

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

output:

26184
13746
53879
74756
18323
28970
47470
57972
34286
25245
61319
34479
13814
60595
62463
63360
27912
61408
23127
50981
54756
35666
63071
72127
20254
65490
57530
51176
67262
78884
27346
72671
5421
33642
76750
43390
53948
52980
39795
70102
15985
66308
51198
49738
33588
18825
62592
47119
57733
65814
5...

result:

ok 100000 numbers

Test #110:

score: 24
Accepted
time: 390ms
memory: 67804kb

input:

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

output:

26479
23046
36774
24865
44391
78375
49346
7754
74043
72476
37596
8906
60787
36825
21658
8554
931
49288
50894
46211
36664
3786
41495
47245
37349
28584
60715
26725
77691
56564
70960
62827
50819
57064
61332
43428
62586
63789
53495
59866
32477
44190
33551
48908
8890
73163
59870
77730
42497
75153
46755
4...

result:

ok 100000 numbers

Test #111:

score: 24
Accepted
time: 390ms
memory: 71656kb

input:

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

output:

18616
52534
54018
54103
39251
67225
40344
75167
69598
74411
62698
47426
70535
30737
33020
70772
51000
70396
75726
12926
38592
43706
33934
55736
68545
65599
17447
68380
34831
60273
77781
52341
42480
69806
71029
69797
38672
68520
67630
47153
67495
58497
61878
54799
43576
68697
31787
22247
26277
37491
...

result:

ok 100000 numbers

Subtask #6:

score: 0
Skipped

Dependency #1:

0%