QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68209#5176. 多控制反转Chinese_zjc_100 ✓4ms3592kbC++141.7kb2022-12-15 10:39:512022-12-15 10:39:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-15 10:39:52]
  • 评测
  • 测评结果:100
  • 用时:4ms
  • 内存:3592kb
  • [2022-12-15 10:39:51]
  • 提交

answer

// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
// #define debug
int n, m, q, c;
typedef std::vector<std::vector<int>> string;
string &operator+=(string &A, const string &B)
{
    A.insert(A.end(), B.begin(), B.end());
    return A;
}
string &operator+=(string &A, const std::vector<int> &B)
{
    A.push_back(B);
    return A;
}
string f(std::vector<int> A, std::vector<int> B, int C)
{
    if (A.size() == 0)
        return {{1, C}};
    if (A.size() == 1)
        return {{2, A[0], C}};
    if (A.size() == 2)
        return {{3, A[0], A[1], C}};
    int ta = A.back(), tb = B.back();
    A.pop_back();
    B.pop_back();
    string res;
    res += {3, ta, tb, C};
    res += f(A, B, tb);
    res += {3, ta, tb, C};
    return res;
}
string work(std::vector<int> A, std::vector<int> B, int C)
{
    string res = f(A, B, C);
    for (int i = res.size(); i--;)
        if (res[i].back() != C)
            res.push_back(res[i]);
    return res;
}
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> n >> m >> q >> c;
    if (n == 0)
    {
        std::cout << "1" << std::endl
                  << "1 0" << std::endl;
        return 0;
    }
    std::vector<int> a(n >> 1), b((n + 1) >> 1);
    std::iota(a.begin(), a.end(), 0);
    std::iota(b.begin(), b.end(), a.size());
    string ans;
    b.push_back(n + 1);
    ans += work(b, a, n);
    b.pop_back();
    ans += work(a, b, n + 1);
    b.push_back(n + 1);
    ans += work(b, a, n);
    b.pop_back();
    ans += work(a, b, n + 1);
    std::cout << ans.size() << std::endl;
    for (auto i : ans)
        for (std::size_t j = 0; j != i.size(); ++j)
            std::cout << i[j] << " \n"[j + 1 == i.size()];
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 2ms
memory: 3396kb

input:

0 2 1 1

output:

1
1 0

result:

ok OK.

Test #2:

score: 0
Accepted
time: 2ms
memory: 3316kb

input:

13 28 105 1

output:

80
3 14 5 13
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 8 0 1
3 6 7 0
3 8 0 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 14 5 13
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 8 0 1
3 6 7 0
3 8 0 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 5 12 14
3 4 11 12
3 3 10 11
3 2 9 10
3 0 1 9
3 2 9 10
3 3 10 11
3 4 11 12
3 5 12 14
3 4...

result:

ok OK.

Test #3:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

5 12 41 1

output:

18
3 6 1 5
3 4 0 1
3 2 3 0
3 4 0 1
3 6 1 5
3 4 0 1
3 2 3 0
3 4 0 1
3 0 1 6
3 6 1 5
3 4 0 1
3 2 3 0
3 4 0 1
3 6 1 5
3 4 0 1
3 2 3 0
3 4 0 1
3 0 1 6

result:

ok OK.

Test #4:

score: 0
Accepted
time: 3ms
memory: 3328kb

input:

20 42 161 1

output:

136
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16 5 6
3 17 6 7
3 18 7 8
3 19 8 9
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16...

result:

ok OK.

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 10
Accepted
time: 3ms
memory: 3544kb

input:

48 98 385 2

output:

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

result:

ok OK.

Test #6:

score: 0
Accepted
time: 3ms
memory: 3348kb

input:

41 84 329 2

output:

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

result:

ok OK.

Test #7:

score: 0
Accepted
time: 3ms
memory: 3512kb

input:

50 102 401 2

output:

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

result:

ok OK.

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #8:

score: 10
Accepted
time: 2ms
memory: 3300kb

input:

0 2 1 3

output:

1
1 0

result:

ok OK.

Test #9:

score: 0
Accepted
time: 0ms
memory: 3268kb

input:

19 40 153 3

output:

128
3 20 8 19
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 11 0 1
3 9 10 0
3 11 0 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16 5 6
3 17 6 7
3 18 7 8
3 20 8 19
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 11 0 1
3 9 10 0
3 11 0 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4...

result:

ok OK.

Test #10:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

47 96 377 3

output:

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

result:

ok OK.

Test #11:

score: 0
Accepted
time: 3ms
memory: 3276kb

input:

25 52 201 3

output:

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

result:

ok OK.

Test #12:

score: 0
Accepted
time: 0ms
memory: 3300kb

input:

50 102 401 3

output:

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

result:

ok OK.

Subtask #4:

score: 10
Accepted

Test #13:

score: 10
Accepted
time: 2ms
memory: 3444kb

input:

0 2 1 4

output:

1
1 0

result:

ok OK.

Test #14:

score: 0
Accepted
time: 2ms
memory: 3416kb

input:

18 20 325 4

output:

120
3 19 8 18
3 17 7 8
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 9 10 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 17 7 8
3 19 8 18
3 17 7 8
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 9 10 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 17 7 8
3 8 17...

result:

ok OK.

Test #15:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

14 16 197 4

output:

88
3 15 6 14
3 13 5 6
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 7 8 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 13 5 6
3 15 6 14
3 13 5 6
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 7 8 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 13 5 6
3 6 13 15
3 5 12 13
3 4 11 12
3 3 10 11
3 2 9 10
3 0 1 9
3 2 9 10
3 3 10 11
3 4 11 12...

result:

ok OK.

Test #16:

score: 0
Accepted
time: 0ms
memory: 3348kb

input:

20 22 401 4

output:

136
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16 5 6
3 17 6 7
3 18 7 8
3 19 8 9
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16...

result:

ok OK.

Subtask #5:

score: 20
Accepted

Dependency #4:

100%
Accepted

Test #17:

score: 20
Accepted
time: 3ms
memory: 3400kb

input:

18 20 325 5

output:

120
3 19 8 18
3 17 7 8
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 9 10 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 17 7 8
3 19 8 18
3 17 7 8
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 9 10 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 17 7 8
3 8 17...

result:

ok OK.

Test #18:

score: 0
Accepted
time: 2ms
memory: 3424kb

input:

17 19 290 5

output:

112
3 18 7 17
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 10 0 1
3 8 9 0
3 10 0 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 18 7 17
3 16 6 7
3 15 5 6
3 14 4 5
3 13 3 4
3 12 2 3
3 11 1 2
3 10 0 1
3 8 9 0
3 10 0 1
3 11 1 2
3 12 2 3
3 13 3 4
3 14 4 5
3 15 5 6
3 16 6 7
3 7 16 1...

result:

ok OK.

Test #19:

score: 0
Accepted
time: 2ms
memory: 3412kb

input:

20 22 401 5

output:

136
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16 5 6
3 17 6 7
3 18 7 8
3 19 8 9
3 21 9 20
3 19 8 9
3 18 7 8
3 17 6 7
3 16 5 6
3 15 4 5
3 14 3 4
3 13 2 3
3 12 1 2
3 10 11 1
3 12 1 2
3 13 2 3
3 14 3 4
3 15 4 5
3 16...

result:

ok OK.

Subtask #6:

score: 10
Accepted

Test #20:

score: 10
Accepted
time: 0ms
memory: 3524kb

input:

14 16 393 6

output:

88
3 15 6 14
3 13 5 6
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 7 8 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 13 5 6
3 15 6 14
3 13 5 6
3 12 4 5
3 11 3 4
3 10 2 3
3 9 1 2
3 7 8 1
3 9 1 2
3 10 2 3
3 11 3 4
3 12 4 5
3 13 5 6
3 6 13 15
3 5 12 13
3 4 11 12
3 3 10 11
3 2 9 10
3 0 1 9
3 2 9 10
3 3 10 11
3 4 11 12...

result:

ok OK.

Test #21:

score: 0
Accepted
time: 2ms
memory: 3492kb

input:

39 41 1093 6

output:

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

result:

ok OK.

Test #22:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

0 2 1 6

output:

1
1 0

result:

ok OK.

Test #23:

score: 0
Accepted
time: 2ms
memory: 3500kb

input:

50 52 1401 6

output:

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

result:

ok OK.

Subtask #7:

score: 10
Accepted

Dependency #2:

100%
Accepted

Dependency #4:

100%
Accepted

Test #24:

score: 10
Accepted
time: 0ms
memory: 3524kb

input:

93 95 745 7

output:

720
3 94 45 93
3 92 44 45
3 91 43 44
3 90 42 43
3 89 41 42
3 88 40 41
3 87 39 40
3 86 38 39
3 85 37 38
3 84 36 37
3 83 35 36
3 82 34 35
3 81 33 34
3 80 32 33
3 79 31 32
3 78 30 31
3 77 29 30
3 76 28 29
3 75 27 28
3 74 26 27
3 73 25 26
3 72 24 25
3 71 23 24
3 70 22 23
3 69 21 22
3 68 20 21
3 67 19 20...

result:

ok OK.

Test #25:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

82 84 657 7

output:

632
3 83 40 82
3 81 39 40
3 80 38 39
3 79 37 38
3 78 36 37
3 77 35 36
3 76 34 35
3 75 33 34
3 74 32 33
3 73 31 32
3 72 30 31
3 71 29 30
3 70 28 29
3 69 27 28
3 68 26 27
3 67 25 26
3 66 24 25
3 65 23 24
3 64 22 23
3 63 21 22
3 62 20 21
3 61 19 20
3 60 18 19
3 59 17 18
3 58 16 17
3 57 15 16
3 56 14 15...

result:

ok OK.

Test #26:

score: 0
Accepted
time: 1ms
memory: 3348kb

input:

100 102 801 7

output:

776
3 101 49 100
3 99 48 49
3 98 47 48
3 97 46 47
3 96 45 46
3 95 44 45
3 94 43 44
3 93 42 43
3 92 41 42
3 91 40 41
3 90 39 40
3 89 38 39
3 88 37 38
3 87 36 37
3 86 35 36
3 85 34 35
3 84 33 34
3 83 32 33
3 82 31 32
3 81 30 31
3 80 29 30
3 79 28 29
3 78 27 28
3 77 26 27
3 76 25 26
3 75 24 25
3 74 23 ...

result:

ok OK.

Subtask #8:

score: 15
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #27:

score: 15
Accepted
time: 3ms
memory: 3388kb

input:

94 96 753 8

output:

728
3 95 46 94
3 93 45 46
3 92 44 45
3 91 43 44
3 90 42 43
3 89 41 42
3 88 40 41
3 87 39 40
3 86 38 39
3 85 37 38
3 84 36 37
3 83 35 36
3 82 34 35
3 81 33 34
3 80 32 33
3 79 31 32
3 78 30 31
3 77 29 30
3 76 28 29
3 75 27 28
3 74 26 27
3 73 25 26
3 72 24 25
3 71 23 24
3 70 22 23
3 69 21 22
3 68 20 21...

result:

ok OK.

Test #28:

score: 0
Accepted
time: 2ms
memory: 3444kb

input:

70 72 561 8

output:

536
3 71 34 70
3 69 33 34
3 68 32 33
3 67 31 32
3 66 30 31
3 65 29 30
3 64 28 29
3 63 27 28
3 62 26 27
3 61 25 26
3 60 24 25
3 59 23 24
3 58 22 23
3 57 21 22
3 56 20 21
3 55 19 20
3 54 18 19
3 53 17 18
3 52 16 17
3 51 15 16
3 50 14 15
3 49 13 14
3 48 12 13
3 47 11 12
3 46 10 11
3 45 9 10
3 44 8 9
3 ...

result:

ok OK.

Test #29:

score: 0
Accepted
time: 4ms
memory: 3476kb

input:

100 102 801 8

output:

776
3 101 49 100
3 99 48 49
3 98 47 48
3 97 46 47
3 96 45 46
3 95 44 45
3 94 43 44
3 93 42 43
3 92 41 42
3 91 40 41
3 90 39 40
3 89 38 39
3 88 37 38
3 87 36 37
3 86 35 36
3 85 34 35
3 84 33 34
3 83 32 33
3 82 31 32
3 81 30 31
3 80 29 30
3 79 28 29
3 78 27 28
3 77 26 27
3 76 25 26
3 75 24 25
3 74 23 ...

result:

ok OK.

Extra Test:

score: 0
Extra Test Passed