QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292079#3269. 末日魔法少女计划SoyTony100 ✓92ms4496kbC++142.8kb2023-12-27 17:22:432023-12-27 17:22:44

Judging History

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

  • [2023-12-27 17:22:44]
  • 评测
  • 测评结果:100
  • 用时:92ms
  • 内存:4496kb
  • [2023-12-27 17:22:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define fir first
#define sec second
const int maxn=2005;
const int maxk=16;
const int inf=0x3f3f3f3f;

inline int read(){
    int x=0,w=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
    while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*w;
}

int f[maxn][maxk],pf[maxn][maxk];
int g[maxn][maxk],pg[maxn][maxk];
inline int f1(int n,int k){
    if(n==1) return 0;
    return f[n-1][k]+n-1;
}
inline int f2(int n,int k){
    if(n==1) return 0;
    if(n==2) return 1;
    return f[n-2][k]+2*n-3;
}

int tot;
vector<pii> I,ans;
inline void link(int l,int r){
    ans.push_back(make_pair(I[l].fir,I[r].sec));
}
void solve(int l,int r,int k){
    if(l>r) return;
    int n=r-l+1;
    if(n<=k) return;
    if(k==1){
        for(int i=l;i<=r;++i){
            for(int j=i+1;j<=r;++j){
                link(i,j);
            }
        }
        return;
    }
    if(k==2){
        int mid=(l+r)>>1;
        for(int i=l;i<mid;++i) link(i,mid);
        for(int i=r;i>mid+1;--i) link(mid+1,i);
        solve(l,mid-1,k),solve(mid+2,r,k);
        return;
    }
    int i=pf[n][k],B=pg[n-2*i][k];
    for(int j=l;j<l+i-1;++j) link(j,l+i-1);
    solve(l,l+i-2,k);
    for(int j=r;j>r-i+1;--j) link(r-i+1,j);
    solve(r-i+2,r,k);
    for(int c=1,L=l+i,R;c<=B;++c,L=R+1){
        R=L+(n-2*i)/B+(c<=(n-2*i)%B)-1;
        for(int j=L;j<R;++j) link(j,R);
        for(int j=R-1;j>L;--j) link(L,j);
        solve(L+1,R-1,k);
    }
    for(int c=1,L=l+i,R;c<=B;++c,L=R+1){
        R=L+(n-2*i)/B+(c<=(n-2*i)%B)-1;
        ++tot;
        I.push_back(make_pair(I[L].fir,I[R].sec));
    }
    solve(tot-B+1,tot,k-2);
}

int main(){
    // freopen("matrix.in","r",stdin);
    // freopen("matrix.out","w",stdout);
    for(int k=1;k<=15;++k){
        for(int n=1;n<=2000;++n){
            if(n<=k) f[n][k]=0;
            else if(k==1) f[n][k]=n*(n-1)/2;
            else if(k==2) f[n][k]=f[(n+1)/2-1][k]+f[n/2-1][k]+n-2;
            else{
                f[n][k]=inf;
                for(int i=1;i<=n/2;++i){
                    ll now=2ll*f1(i,k)+g[n-2*i][k];
                    if(now<f[n][k]) f[n][k]=now,pf[n][k]=i;
                }
            }
            if(k<=2) continue;
            g[n][k]=inf;
            for(int B=1;B<=n;++B){
                ll now=f[B][k-2]+1ll*(n%B)*f2(n/B+1,k)+1ll*(B-n%B)*f2(n/B,k);
                if(now<g[n][k]) g[n][k]=now,pg[n][k]=B;
            }
        }
    }
    int n=read(),k=read();
    I.push_back(make_pair(0,0));
    for(int i=1;i<=n;++i){
        ++tot;
        I.push_back(make_pair(i,i));
    }
    solve(1,n,k);
    printf("%ld\n",ans.size());
    for(pii p:ans) printf("%d %d\n",p.fir-1,p.sec);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 22
Accepted

Test #1:

score: 22
Accepted
time: 83ms
memory: 4392kb

input:

2000 2

output:

15974
0 1000
1 1000
2 1000
3 1000
4 1000
5 1000
6 1000
7 1000
8 1000
9 1000
10 1000
11 1000
12 1000
13 1000
14 1000
15 1000
16 1000
17 1000
18 1000
19 1000
20 1000
21 1000
22 1000
23 1000
24 1000
25 1000
26 1000
27 1000
28 1000
29 1000
30 1000
31 1000
32 1000
33 1000
34 1000
35 1000
36 1000
37 1000
...

result:

ok 

Test #2:

score: 22
Accepted
time: 82ms
memory: 4360kb

input:

1999 2

output:

15965
0 1000
1 1000
2 1000
3 1000
4 1000
5 1000
6 1000
7 1000
8 1000
9 1000
10 1000
11 1000
12 1000
13 1000
14 1000
15 1000
16 1000
17 1000
18 1000
19 1000
20 1000
21 1000
22 1000
23 1000
24 1000
25 1000
26 1000
27 1000
28 1000
29 1000
30 1000
31 1000
32 1000
33 1000
34 1000
35 1000
36 1000
37 1000
...

result:

ok 

Test #3:

score: 22
Accepted
time: 87ms
memory: 4368kb

input:

1992 2

output:

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

result:

ok 

Test #4:

score: 22
Accepted
time: 78ms
memory: 4376kb

input:

1973 2

output:

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

result:

ok 

Test #5:

score: 22
Accepted
time: 73ms
memory: 4484kb

input:

1936 2

output:

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

result:

ok 

Subtask #2:

score: 14
Accepted

Test #6:

score: 14
Accepted
time: 89ms
memory: 4436kb

input:

1936 3

output:

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

result:

ok 

Test #7:

score: 14
Accepted
time: 81ms
memory: 4484kb

input:

2000 3

output:

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

result:

ok 

Test #8:

score: 14
Accepted
time: 81ms
memory: 4380kb

input:

1999 3

output:

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

result:

ok 

Test #9:

score: 14
Accepted
time: 81ms
memory: 4428kb

input:

1992 3

output:

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

result:

ok 

Test #10:

score: 14
Accepted
time: 81ms
memory: 4420kb

input:

1973 3

output:

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

result:

ok 

Subtask #3:

score: 11
Accepted

Test #11:

score: 11
Accepted
time: 80ms
memory: 4356kb

input:

2000 4

output:

4792
0 37
1 37
2 37
3 37
4 37
5 37
6 37
7 37
8 37
9 37
10 37
11 37
12 37
13 37
14 37
15 37
16 37
17 37
18 37
19 37
20 37
21 37
22 37
23 37
24 37
25 37
26 37
27 37
28 37
29 37
30 37
31 37
32 37
33 37
34 37
35 37
0 5
1 5
2 5
3 5
31 36
31 35
31 34
31 33
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
...

result:

ok 

Test #12:

score: 11
Accepted
time: 81ms
memory: 4368kb

input:

1999 4

output:

4789
0 39
1 39
2 39
3 39
4 39
5 39
6 39
7 39
8 39
9 39
10 39
11 39
12 39
13 39
14 39
15 39
16 39
17 39
18 39
19 39
20 39
21 39
22 39
23 39
24 39
25 39
26 39
27 39
28 39
29 39
30 39
31 39
32 39
33 39
34 39
35 39
36 39
37 39
0 5
1 5
2 5
3 5
33 38
33 37
33 36
33 35
5 7
7 9
9 11
11 13
13 15
15 17
17 19
...

result:

ok 

Test #13:

score: 11
Accepted
time: 80ms
memory: 4444kb

input:

1991 4

output:

4768
0 39
1 39
2 39
3 39
4 39
5 39
6 39
7 39
8 39
9 39
10 39
11 39
12 39
13 39
14 39
15 39
16 39
17 39
18 39
19 39
20 39
21 39
22 39
23 39
24 39
25 39
26 39
27 39
28 39
29 39
30 39
31 39
32 39
33 39
34 39
35 39
36 39
37 39
0 5
1 5
2 5
3 5
33 38
33 37
33 36
33 35
5 7
7 9
9 11
11 13
13 15
15 17
17 19
...

result:

ok 

Test #14:

score: 11
Accepted
time: 88ms
memory: 4432kb

input:

1971 4

output:

4715
0 37
1 37
2 37
3 37
4 37
5 37
6 37
7 37
8 37
9 37
10 37
11 37
12 37
13 37
14 37
15 37
16 37
17 37
18 37
19 37
20 37
21 37
22 37
23 37
24 37
25 37
26 37
27 37
28 37
29 37
30 37
31 37
32 37
33 37
34 37
35 37
0 5
1 5
2 5
3 5
31 36
31 35
31 34
31 33
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
...

result:

ok 

Test #15:

score: 11
Accepted
time: 81ms
memory: 4404kb

input:

1938 4

output:

4626
0 39
1 39
2 39
3 39
4 39
5 39
6 39
7 39
8 39
9 39
10 39
11 39
12 39
13 39
14 39
15 39
16 39
17 39
18 39
19 39
20 39
21 39
22 39
23 39
24 39
25 39
26 39
27 39
28 39
29 39
30 39
31 39
32 39
33 39
34 39
35 39
36 39
37 39
0 5
1 5
2 5
3 5
33 38
33 37
33 36
33 35
5 7
7 9
9 11
11 13
13 15
15 17
17 19
...

result:

ok 

Subtask #4:

score: 9
Accepted

Test #16:

score: 9
Accepted
time: 80ms
memory: 4332kb

input:

2000 5

output:

3922
0 34
1 34
2 34
3 34
4 34
5 34
6 34
7 34
8 34
9 34
10 34
11 34
12 34
13 34
14 34
15 34
16 34
17 34
18 34
19 34
20 34
21 34
22 34
23 34
24 34
25 34
26 34
27 34
28 34
29 34
30 34
31 34
32 34
0 5
1 5
2 5
3 5
28 33
28 32
28 31
28 30
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
5 13
7...

result:

ok 

Test #17:

score: 9
Accepted
time: 77ms
memory: 4420kb

input:

1999 5

output:

3920
0 34
1 34
2 34
3 34
4 34
5 34
6 34
7 34
8 34
9 34
10 34
11 34
12 34
13 34
14 34
15 34
16 34
17 34
18 34
19 34
20 34
21 34
22 34
23 34
24 34
25 34
26 34
27 34
28 34
29 34
30 34
31 34
32 34
0 5
1 5
2 5
3 5
28 33
28 32
28 31
28 30
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
5 13
7...

result:

ok 

Test #18:

score: 9
Accepted
time: 80ms
memory: 4320kb

input:

1992 5

output:

3906
0 30
1 30
2 30
3 30
4 30
5 30
6 30
7 30
8 30
9 30
10 30
11 30
12 30
13 30
14 30
15 30
16 30
17 30
18 30
19 30
20 30
21 30
22 30
23 30
24 30
25 30
26 30
27 30
28 30
0 3
1 3
26 29
26 28
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
3 11
5 11
7 11
19 26
19 25
19 23
11 15
15 19
11 19
1...

result:

ok 

Test #19:

score: 9
Accepted
time: 81ms
memory: 4456kb

input:

1973 5

output:

3866
0 35
1 35
2 35
3 35
4 35
5 35
6 35
7 35
8 35
9 35
10 35
11 35
12 35
13 35
14 35
15 35
16 35
17 35
18 35
19 35
20 35
21 35
22 35
23 35
24 35
25 35
26 35
27 35
28 35
29 35
30 35
31 35
32 35
33 35
0 5
1 5
2 5
3 5
29 34
29 33
29 32
29 31
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
...

result:

ok 

Test #20:

score: 9
Accepted
time: 77ms
memory: 4420kb

input:

1936 5

output:

3792
0 16
1 16
2 16
3 16
4 16
5 16
6 16
7 16
8 16
9 16
10 16
11 16
12 16
13 16
14 16
1 3
3 5
5 7
7 9
9 11
11 13
1 5
11 14
5 9
5 11
1920 1936
1920 1935
1920 1934
1920 1933
1920 1932
1920 1931
1920 1930
1920 1929
1920 1928
1920 1927
1920 1926
1920 1925
1920 1924
1920 1923
1920 1922
1922 1924
1924 1926...

result:

ok 

Subtask #5:

score: 7
Accepted

Test #21:

score: 7
Accepted
time: 81ms
memory: 4328kb

input:

2000 6

output:

3213
0 7
1 7
2 7
3 7
4 7
5 7
1993 2000
1993 1999
1993 1998
1993 1997
1993 1996
1993 1995
7 10
8 10
7 9
10 13
11 13
10 12
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73...

result:

ok 

Test #22:

score: 7
Accepted
time: 89ms
memory: 4388kb

input:

1997 6

output:

3208
0 7
1 7
2 7
3 7
4 7
5 7
1990 1997
1990 1996
1990 1995
1990 1994
1990 1993
1990 1992
7 10
8 10
7 9
10 13
11 13
10 12
13 16
14 16
13 15
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70...

result:

ok 

Test #23:

score: 7
Accepted
time: 81ms
memory: 4352kb

input:

1989 6

output:

3194
0 7
1 7
2 7
3 7
4 7
5 7
1982 1989
1982 1988
1982 1987
1982 1986
1982 1985
1982 1984
7 10
8 10
7 9
10 13
11 13
10 12
13 16
14 16
13 15
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70...

result:

ok 

Test #24:

score: 7
Accepted
time: 76ms
memory: 4328kb

input:

1972 6

output:

3164
0 7
1 7
2 7
3 7
4 7
5 7
1965 1972
1965 1971
1965 1970
1965 1969
1965 1968
1965 1967
7 10
8 10
7 9
10 13
11 13
10 12
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73...

result:

ok 

Test #25:

score: 7
Accepted
time: 80ms
memory: 4412kb

input:

1933 6

output:

3096
0 7
1 7
2 7
3 7
4 7
5 7
1926 1933
1926 1932
1926 1931
1926 1930
1926 1929
1926 1928
7 10
8 10
7 9
10 13
11 13
10 12
13 16
14 16
13 15
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70...

result:

ok 

Subtask #6:

score: 6
Accepted

Test #26:

score: 6
Accepted
time: 81ms
memory: 4396kb

input:

1999 7

output:

2901
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1991 1999
1991 1998
1991 1997
1991 1996
1991 1995
1991 1994
1991 1993
8 11
9 11
8 10
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71...

result:

ok 

Test #27:

score: 6
Accepted
time: 80ms
memory: 4328kb

input:

1997 7

output:

2898
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1989 1997
1989 1996
1989 1995
1989 1994
1989 1993
1989 1992
1989 1991
8 11
9 11
8 10
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71...

result:

ok 

Test #28:

score: 6
Accepted
time: 81ms
memory: 4400kb

input:

1987 7

output:

2883
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1979 1987
1979 1986
1979 1985
1979 1984
1979 1983
1979 1982
1979 1981
8 11
9 11
8 10
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71...

result:

ok 

Test #29:

score: 6
Accepted
time: 80ms
memory: 4440kb

input:

1978 7

output:

2869
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1970 1978
1970 1977
1970 1976
1970 1975
1970 1974
1970 1973
1970 1972
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #30:

score: 6
Accepted
time: 81ms
memory: 4400kb

input:

1931 7

output:

2799
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1923 1931
1923 1930
1923 1929
1923 1928
1923 1927
1923 1926
1923 1925
8 11
9 11
8 10
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71...

result:

ok 

Subtask #7:

score: 5
Accepted

Test #31:

score: 5
Accepted
time: 80ms
memory: 4332kb

input:

1995 8

output:

2501
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1987 1995
1987 1994
1987 1993
1987 1992
1987 1991
1987 1990
1987 1989
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #32:

score: 5
Accepted
time: 77ms
memory: 4440kb

input:

1999 8

output:

2506
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1991 1999
1991 1998
1991 1997
1991 1996
1991 1995
1991 1994
1991 1993
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #33:

score: 5
Accepted
time: 80ms
memory: 4332kb

input:

1987 8

output:

2490
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1978 1987
1978 1986
1978 1985
1978 1984
1978 1983
1978 1982
1978 1981
1978 1980
9 12
10 12
9 11
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68...

result:

ok 

Test #34:

score: 5
Accepted
time: 82ms
memory: 4388kb

input:

1981 8

output:

2481
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1972 1981
1972 1980
1972 1979
1972 1978
1972 1977
1972 1976
1972 1975
1972 1974
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #35:

score: 5
Accepted
time: 76ms
memory: 4320kb

input:

1923 8

output:

2405
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1915 1923
1915 1922
1915 1921
1915 1920
1915 1919
1915 1918
1915 1917
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Subtask #8:

score: 5
Accepted

Test #36:

score: 5
Accepted
time: 80ms
memory: 4340kb

input:

1997 9

output:

2392
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1988 1997
1988 1996
1988 1995
1988 1994
1988 1993
1988 1992
1988 1991
1988 1990
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #37:

score: 5
Accepted
time: 77ms
memory: 4444kb

input:

1998 9

output:

2393
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1989 1998
1989 1997
1989 1996
1989 1995
1989 1994
1989 1993
1989 1992
1989 1991
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #38:

score: 5
Accepted
time: 80ms
memory: 4320kb

input:

1990 9

output:

2383
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1981 1990
1981 1989
1981 1988
1981 1987
1981 1986
1981 1985
1981 1984
1981 1983
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #39:

score: 5
Accepted
time: 85ms
memory: 4288kb

input:

1975 9

output:

2364
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1965 1975
1965 1974
1965 1973
1965 1972
1965 1971
1965 1970
1965 1969
1965 1968
1965 1967
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Test #40:

score: 5
Accepted
time: 76ms
memory: 4496kb

input:

1934 9

output:

2313
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1925 1934
1925 1933
1925 1932
1925 1931
1925 1930
1925 1929
1925 1928
1925 1927
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Subtask #9:

score: 4
Accepted

Test #41:

score: 4
Accepted
time: 81ms
memory: 4312kb

input:

1995 10

output:

2193
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1987 1995
1987 1994
1987 1993
1987 1992
1987 1991
1987 1990
1987 1989
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #42:

score: 4
Accepted
time: 80ms
memory: 4400kb

input:

1996 10

output:

2194
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1988 1996
1988 1995
1988 1994
1988 1993
1988 1992
1988 1991
1988 1990
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #43:

score: 4
Accepted
time: 80ms
memory: 4348kb

input:

1979 10

output:

2175
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1971 1979
1971 1978
1971 1977
1971 1976
1971 1975
1971 1974
1971 1973
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #44:

score: 4
Accepted
time: 81ms
memory: 4400kb

input:

1972 10

output:

2166
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1962 1972
1962 1971
1962 1970
1962 1969
1962 1968
1962 1967
1962 1966
1962 1965
1962 1964
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Test #45:

score: 4
Accepted
time: 80ms
memory: 4360kb

input:

1945 10

output:

2135
0 11
1 11
2 11
3 11
4 11
5 11
6 11
7 11
8 11
9 11
1934 1945
1934 1944
1934 1943
1934 1942
1934 1941
1934 1940
1934 1939
1934 1938
1934 1937
1934 1936
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
5...

result:

ok 

Subtask #10:

score: 4
Accepted

Test #46:

score: 4
Accepted
time: 85ms
memory: 4364kb

input:

1993 11

output:

2133
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1984 1993
1984 1992
1984 1991
1984 1990
1984 1989
1984 1988
1984 1987
1984 1986
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #47:

score: 4
Accepted
time: 84ms
memory: 4400kb

input:

1994 11

output:

2134
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1985 1994
1985 1993
1985 1992
1985 1991
1985 1990
1985 1989
1985 1988
1985 1987
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #48:

score: 4
Accepted
time: 81ms
memory: 4416kb

input:

2000 11

output:

2140
0 12
1 12
2 12
3 12
4 12
5 12
6 12
7 12
8 12
9 12
10 12
1988 2000
1988 1999
1988 1998
1988 1997
1988 1996
1988 1995
1988 1994
1988 1993
1988 1992
1988 1991
1988 1990
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 ...

result:

ok 

Test #49:

score: 4
Accepted
time: 92ms
memory: 4340kb

input:

1972 11

output:

2109
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1962 1972
1962 1971
1962 1970
1962 1969
1962 1968
1962 1967
1962 1966
1962 1965
1962 1964
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Test #50:

score: 4
Accepted
time: 80ms
memory: 4400kb

input:

1944 11

output:

2077
0 12
1 12
2 12
3 12
4 12
5 12
6 12
7 12
8 12
9 12
10 12
1932 1944
1932 1943
1932 1942
1932 1941
1932 1940
1932 1939
1932 1938
1932 1937
1932 1936
1932 1935
1932 1934
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 ...

result:

ok 

Subtask #11:

score: 4
Accepted

Test #51:

score: 4
Accepted
time: 81ms
memory: 4312kb

input:

1999 12

output:

2067
0 6
1 6
2 6
3 6
4 6
1993 1999
1993 1998
1993 1997
1993 1996
1993 1995
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
...

result:

ok 

Test #52:

score: 4
Accepted
time: 80ms
memory: 4312kb

input:

2000 12

output:

2068
0 6
1 6
2 6
3 6
4 6
1994 2000
1994 1999
1994 1998
1994 1997
1994 1996
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
...

result:

ok 

Test #53:

score: 4
Accepted
time: 81ms
memory: 4400kb

input:

1989 12

output:

2056
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
1980 1989
1980 1988
1980 1987
1980 1986
1980 1985
1980 1984
1980 1983
1980 1982
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 7...

result:

ok 

Test #54:

score: 4
Accepted
time: 78ms
memory: 4384kb

input:

1976 12

output:

2042
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1966 1976
1966 1975
1966 1974
1966 1973
1966 1972
1966 1971
1966 1970
1966 1969
1966 1968
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Test #55:

score: 4
Accepted
time: 81ms
memory: 4304kb

input:

1949 12

output:

2013
0 13
1 13
2 13
3 13
4 13
5 13
6 13
7 13
8 13
9 13
10 13
11 13
1936 1949
1936 1948
1936 1947
1936 1946
1936 1945
1936 1944
1936 1943
1936 1942
1936 1941
1936 1940
1936 1939
1936 1938
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51...

result:

ok 

Subtask #12:

score: 3
Accepted

Test #56:

score: 3
Accepted
time: 91ms
memory: 4288kb

input:

1981 13

output:

2004
1 3
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 95
95 97
97 99
99 101
101...

result:

ok 

Test #57:

score: 3
Accepted
time: 82ms
memory: 4428kb

input:

1982 13

output:

2005
1 3
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 95
95 97
97 99
99 101
101...

result:

ok 

Test #58:

score: 3
Accepted
time: 77ms
memory: 4360kb

input:

1989 13

output:

2012
0 3
1 3
1986 1989
1986 1988
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 9...

result:

ok 

Test #59:

score: 3
Accepted
time: 80ms
memory: 4424kb

input:

1972 13

output:

1994
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1962 1972
1962 1971
1962 1970
1962 1969
1962 1968
1962 1967
1962 1966
1962 1965
1962 1964
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Test #60:

score: 3
Accepted
time: 77ms
memory: 4380kb

input:

1929 13

output:

1949
0 5
1 5
2 5
3 5
1924 1929
1924 1928
1924 1927
1924 1926
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 8...

result:

ok 

Subtask #13:

score: 3
Accepted

Test #61:

score: 3
Accepted
time: 80ms
memory: 4488kb

input:

1979 14

output:

1981
1 3
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 95
95 97
97 99
99 101
101...

result:

ok 

Test #62:

score: 3
Accepted
time: 80ms
memory: 4424kb

input:

1980 14

output:

1982
1 3
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 95
95 97
97 99
99 101
101...

result:

ok 

Test #63:

score: 3
Accepted
time: 81ms
memory: 4284kb

input:

1987 14

output:

1989
0 4
1 4
2 4
1983 1987
1983 1986
1983 1985
4 6
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
82 84
84 86
86 88
88 90
...

result:

ok 

Test #64:

score: 3
Accepted
time: 90ms
memory: 4420kb

input:

1952 14

output:

1953
0 2
1950 1952
2 4
4 6
6 8
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
74 76
76 78
78 80
80 82
82 84
84 86
86 88
88 90
90 92
92 94
94 96
96 98
...

result:

ok 

Test #65:

score: 3
Accepted
time: 81ms
memory: 4360kb

input:

1936 14

output:

1936
0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1926 1936
1926 1935
1926 1934
1926 1933
1926 1932
1926 1931
1926 1930
1926 1929
1926 1928
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 6...

result:

ok 

Subtask #14:

score: 3
Accepted

Test #66:

score: 3
Accepted
time: 80ms
memory: 4308kb

input:

2000 15

output:

1988
0 12
1 12
2 12
3 12
4 12
5 12
6 12
7 12
8 12
9 12
10 12
1988 2000
1988 1999
1988 1998
1988 1997
1988 1996
1988 1995
1988 1994
1988 1993
1988 1992
1988 1991
1988 1990
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 ...

result:

ok 

Test #67:

score: 3
Accepted
time: 83ms
memory: 4340kb

input:

1999 15

output:

1987
0 12
1 12
2 12
3 12
4 12
5 12
6 12
7 12
8 12
9 12
10 12
1987 1999
1987 1998
1987 1997
1987 1996
1987 1995
1987 1994
1987 1993
1987 1992
1987 1991
1987 1990
1987 1989
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 ...

result:

ok 

Test #68:

score: 3
Accepted
time: 81ms
memory: 4312kb

input:

1992 15

output:

1980
0 8
1 8
2 8
3 8
4 8
5 8
6 8
1984 1992
1984 1991
1984 1990
1984 1989
1984 1988
1984 1987
1984 1986
8 10
10 12
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 56
56 58
58 60
60 62
62 64
64 66
66 68
68 70
70 72
72 74
...

result:

ok 

Test #69:

score: 3
Accepted
time: 80ms
memory: 4312kb

input:

1973 15

output:

1961
1 3
3 5
5 7
7 9
9 11
11 13
13 15
15 17
17 19
19 21
21 23
23 25
25 27
27 29
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
45 47
47 49
49 51
51 53
53 55
55 57
57 59
59 61
61 63
63 65
65 67
67 69
69 71
71 73
73 75
75 77
77 79
79 81
81 83
83 85
85 87
87 89
89 91
91 93
93 95
95 97
97 99
99 101
101...

result:

ok 

Test #70:

score: 3
Accepted
time: 84ms
memory: 4288kb

input:

1936 15

output:

1923
0 12
1 12
2 12
3 12
4 12
5 12
6 12
7 12
8 12
9 12
10 12
1924 1936
1924 1935
1924 1934
1924 1933
1924 1932
1924 1931
1924 1930
1924 1929
1924 1928
1924 1927
1924 1926
12 14
14 16
16 18
18 20
20 22
22 24
24 26
26 28
28 30
30 32
32 34
34 36
36 38
38 40
40 42
42 44
44 46
46 48
48 50
50 52
52 54
54 ...

result:

ok