QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312059#6319. Parallel Processing (Easy)PlentyOfPenalty#WA 1ms3772kbC++173.6kb2024-01-23 12:13:132024-01-23 12:13:13

Judging History

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

  • [2024-01-23 12:13:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-01-23 12:13:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 9;
struct atom {
    int l, r;
    atom operator+(const atom &rhs) const {
        assert(r + 1 == rhs.l);
        return {l, rhs.r};
    }
} a[N], c[4];
int n;
struct oper {
    int a, b, c;
    bool ok() const { return a && b && c && a <= n && b <= n && c <= n; }
};
vector<array<oper, 4>> ans;
int main() {
#ifdef popteam
    freopen("C.in", "r", stdin);
#endif
    for (int i = 0; i < N; i++)
        a[i].l = a[i].r = i;
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    if (n >= 2)
        ans.push_back({
            oper{1, 2, 2},
            oper{3, 4, 4},
            oper{5, 6, 6},
            oper{7, 8, 8},
        });
    if (n >= 3)
        ans.push_back({
            oper{2, 3, 3}, // 灵活就业 ans[1][0]
            oper{2, 4, 4},
            oper{6, 7, 7},
            oper{6, 8, 8},
        });
    if (n >= 5)
        ans.push_back({
            oper{4, 5, 5}, // 灵活就业 ans[2][0]
            oper{4, 6, 6}, // 灵活就业 ans[2][1]
            oper{4, 7, 7}, // 灵活就业 ans[2][2]
            oper{4, 8, 8},
        });
    if (n >= 9)
        ans.push_back({
            oper{8, 9, 9},
            oper{8, 10, 10},
            oper{8, 11, 11},
            oper{8, 12, 12},
        });
    if (n >= 13)
        ans.push_back({
            oper{8, 13, 13},
            oper{8, 14, 14},
            oper{8, 15, 15},
            oper{8, 16, 16},
        });
    if (n > 9) {
        if (n == 10) {
            swap(ans[3][2], ans[1][0]);
            ans[1][0] = {9, 10, 10};
        } else if (11 <= n && n <= 12) {
            ans.insert(ans.begin() + 3, {
                                            oper{9, 10, 10},
                                            oper{10, 11, 11},
                                            oper{11, 12, 12},
                                            oper{10, 12, 12},
                                        });
            swap(ans[1][0], ans[3][0]);
            swap(ans[2][0], ans[3][1]);
            swap(ans[2][1], ans[3][2]);
            // if (n == 13 || n == 14) {
            //     ans.insert(ans.begin() + 4, {
            //                                     oper{12, 13, 13},
            //                                     oper{13, 14, 14},
            //                                 });
            //     swap(ans[2][2], ans[4][0]);
            // }
        } else {
            auto tmp = ans;
            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 4; j++) {
                    tmp[i][j].a += 8;
                    tmp[i][j].b += 8;
                    tmp[i][j].c += 8;
                }
            ans.insert(ans.begin() + 3, tmp[0]);
            ans.insert(ans.begin() + 4, tmp[1]);
            ans.insert(ans.begin() + 5, tmp[2]);
        }
    }
    cout << ans.size() << endl;
    for (const auto &op : ans) {
        for (int i = 0; i < 4; i++)
            if (op[i].ok()) {
                cout << op[i].b << " " << op[i].a << " " << op[i].c << endl;
                c[i] = a[op[i].a] + a[op[i].b];
            } else {
                cout << "2000 2000 2000" << endl;
            }
        for (int i = 0; i < 4; i++)
            if (op[i].ok()) a[op[i].c] = c[i];
        cerr << ">> ";
        for (int i = 1; i <= n; i++)
            cerr << a[i].l << "," << a[i].r << "  ";
        cerr << endl;
    }
    for (int i = 1; i <= n; i++) {
        assert(a[i].l == 1 && a[i].r == i);
    }
    cerr << "size = " << ans.size() << endl;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3528kb

input:

2

output:

1
2 1 2
2000 2000 2000
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #2:

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

input:

4

output:

2
2 1 2
4 3 4
2000 2000 2000
2000 2000 2000
3 2 3
4 2 4
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #3:

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

input:

3

output:

2
2 1 2
2000 2000 2000
2000 2000 2000
2000 2000 2000
3 2 3
2000 2000 2000
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #4:

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

input:

5

output:

3
2 1 2
4 3 4
2000 2000 2000
2000 2000 2000
3 2 3
4 2 4
2000 2000 2000
2000 2000 2000
5 4 5
2000 2000 2000
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #5:

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

input:

6

output:

3
2 1 2
4 3 4
6 5 6
2000 2000 2000
3 2 3
4 2 4
2000 2000 2000
2000 2000 2000
5 4 5
6 4 6
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #6:

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

input:

7

output:

3
2 1 2
4 3 4
6 5 6
2000 2000 2000
3 2 3
4 2 4
7 6 7
2000 2000 2000
5 4 5
6 4 6
7 4 7
2000 2000 2000

result:

ok AC

Test #7:

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

input:

8

output:

3
2 1 2
4 3 4
6 5 6
8 7 8
3 2 3
4 2 4
7 6 7
8 6 8
5 4 5
6 4 6
7 4 7
8 4 8

result:

ok AC

Test #8:

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

input:

9

output:

4
2 1 2
4 3 4
6 5 6
8 7 8
3 2 3
4 2 4
7 6 7
8 6 8
5 4 5
6 4 6
7 4 7
8 4 8
9 8 9
2000 2000 2000
2000 2000 2000
2000 2000 2000

result:

ok AC

Test #9:

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

input:

10

output:

4
2 1 2
4 3 4
6 5 6
8 7 8
10 9 10
4 2 4
7 6 7
8 6 8
5 4 5
6 4 6
7 4 7
8 4 8
9 8 9
10 8 10
3 2 3
2000 2000 2000

result:

ok AC

Test #10:

score: -100
Wrong Answer
time: 1ms
memory: 3592kb

input:

11

output:

5
2 1 2
4 3 4
6 5 6
8 7 8
10 9 10
4 2 4
7 6 7
8 6 8
11 10 11
2000 2000 2000
7 4 7
8 4 8
3 2 3
5 4 5
6 4 6
2000 2000 2000
9 8 9
10 8 10
11 8 11
2000 2000 2000

result:

wrong answer L = 5 is larger than 4