QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#525684#2674. Vision programarbuzick#0 2ms4388kbC++203.7kb2024-08-20 20:23:152024-08-20 20:23:17

Judging History

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

  • [2024-08-20 20:23:17]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:4388kb
  • [2024-08-20 20:23:15]
  • 提交

answer

#include "vision.h"

#include <bits/stdc++.h>

using namespace std;

vector<int> multiply(vector<int> a, vector<int> b) {
    vector<int> res(a.size() + b.size() - 1);
    if (a.size() == 1) {
        for (int i = 0; i < (int)res.size(); ++i) {
            res[i] = add_and({a[0], b[i]});
        }
        return res;
    }
    vector<int> a1, a2, b1, b2;
    for (int i = 0; i < (int)a.size() / 2; ++i) {
        a1.push_back(a[i]);
    }
    for (int i = (int)a.size() / 2; i < (int)a.size(); ++i) {
        a2.push_back(a[i]);
    }
    for (int i = 0; i < (int)b.size() / 2; ++i) {
        b1.push_back(b[i]);
    }
    for (int i = (int)b.size() / 2; i < (int)b.size(); ++i) {
        b2.push_back(b[i]);
    }

    vector<int> a12(max(a1.size(), a2.size())), b12(max(b1.size(), b2.size()));
    for (int i = 0; i < (int)a12.size(); ++i) {
        if (i < (int)a1.size() && i < (int)a2.size()) {
            a12[i] = add_or({a1[i], a2[i]});
        } else if (i < (int)a1.size()) {
            a12[i] = a1[i];
        } else {
            a12[i] = a2[i];
        }
    }
    for (int i = 0; i < (int)b12.size(); ++i) {
        if (i < (int)b1.size() && i < (int)b2.size()) {
            b12[i] = add_or({b1[i], b2[i]});
        } else if (i < (int)b1.size()) {
            b12[i] = b1[i];
        } else {
            b12[i] = b2[i];
        }
    }

    vector<int> res1 = multiply(a1, b1), res2 = multiply(a12, b12), res3 = multiply(a2, b2);
    for (int i = 0; i < (int)res2.size(); ++i) {
        if (i < (int)res1.size() && i < (int)res3.size()) {
            int tmp = add_or({res1[i], res3[i]});
            res2[i] = add_xor({res2[i], tmp});
        } else if (i < (int)res1.size()) {
            res2[i] = add_xor({res2[i], res1[i]});
        } else {
            res2[i] = add_xor({res2[i], res3[i]});
        }
    }
    vector<vector<int>> temp(res.size());
    for (int i = 0; i < (int)res1.size(); ++i) {
        temp[i].push_back(res1[i]);
    }
    for (int i = 0; i < (int)res2.size(); ++i) {
        temp[i + a1.size()].push_back(res2[i]);
    }
    for (int i = 0; i < (int)res3.size(); ++i) {
        temp[i + a1.size() + b1.size()].push_back(res3[i]);
    }

    for (int i = 0; i < (int)res.size(); ++i) {
        if (temp[i].size() == 1) {
            res[i] = temp[i][0];
        } else {
            res[i] = add_or(temp[i]);
        }
    }
    return res;
}

void construct_network(int h, int w, int k) {
    vector<int> hs(h), ws(w);
    for (int i = 0; i < h; ++i) {
        vector<int> ns;
        for (int j = 0; j < w; ++j) {
            ns.push_back(i * w + j);
        }
        hs[i] = add_or(ns);
    }
    for (int i = 0; i < w; ++i) {
        vector<int> ns;
        for (int j = 0; j < h; ++j) {
            ns.push_back(j * w + i);
        }
        ws[i] = add_or(ns);
    }
    vector<int> hd(h), wd(w);
    vector<int> a = hs, b = hs;
    reverse(b.begin(), b.end());
    vector<int> res = multiply(a, b);
    hd[0] = add_xor(hs);
    for (int i = 1; i < h; ++i) {
        hd[i] = add_or({res[h - 1 - i], res[h - 1 + i]});
    }
    a = ws, b = ws;
    reverse(b.begin(), b.end());
    res = multiply(a, b);
    wd[0] = add_xor(ws);
    for (int i = 1; i < w; ++i) {
        wd[i] = add_or({res[w - 1 - i], res[w - 1 + i]});
    }
    vector<int> temp;
    for (int i = 0; i < (int)hd.size() && i <= k; ++i) {
        if (k - i < (int)wd.size()) {
            if (w != 1 && h != 1) {
                temp.push_back(add_and({hd[i], wd[k - i]}));
            } else if (i == 0 || i == k) {
                temp.push_back(add_and({hd[i], wd[k - i]}));
            }
        }
    }
    add_or(temp);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3876kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
1 3 1
-1

output:

b17553fd-ba5a-4140-836c-491f938c515b
OK
34
1 3 0 1 2
1 1 0
1 1 1
1 1 2
0 2 3 3
2 1 3
1 2 4 5
1 2 6 5
0 2 4 6
1 2 9 6
1 2 10 4
0 2 9 10
0 2 12 13
0 2 6 4
1 2 14 16
2 2 15 17
1 2 5 6
1 2 5 4
0 2 5 5
0 2 19 20
0 2 6 4
1 2 21 23
2 2 22 24
1 2 11 21
2 2 14 26
2 2 18 25
2 2 16 23
1 2 28 21
1 2 29 25
2 3 4...

result:

wrong answer on inputs (0, 0), (0, 1), expected 1, but computed 0

Subtask #2:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 3832kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
1 9 3
-1

output:

b17553fd-ba5a-4140-836c-491f938c515b
OK
226
1 9 0 1 2 3 4 5 6 7 8
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
0 2 9 9
2 1 9
1 2 10 14
1 2 11 15
1 2 12 16
1 2 13 17
1 2 18 14
1 2 17 13
1 2 16 12
1 2 15 11
1 2 10 12
1 2 11 13
1 2 18 16
1 2 17 15
1 2 10 11
1 2 18 17
0 2 10 18
0 2 33 34
0 2 11...

result:

wrong answer on inputs (0, 1), (0, 4), expected 1, but computed 0

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #48:

score: 0
Wrong Answer
time: 2ms
memory: 4056kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
1 199 1
-1

output:

b17553fd-ba5a-4140-836c-491f938c515b
WA
Too many instructions

result:

wrong answer WA in grader: Too many instructions

Subtask #6:

score: 0
Wrong Answer

Test #70:

score: 8
Accepted
time: 0ms
memory: 4072kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
2 2 1
3 128
128 129
128 130
128 131

output:

b17553fd-ba5a-4140-836c-491f938c515b
OK
25
1 2 0 1
1 2 2 3
1 2 0 2
1 2 1 3
1 2 4 5
1 2 5 4
0 2 4 5
0 2 8 9
0 2 5 4
1 2 10 12
2 2 11 13
2 2 4 5
1 2 10 12
1 2 6 7
1 2 7 6
0 2 6 7
0 2 17 18
0 2 7 6
1 2 19 21
2 2 20 22
2 2 6 7
1 2 19 21
0 2 15 25
0 2 16 24
1 2 26 27

result:

ok 

Test #71:

score: 8
Accepted
time: 0ms
memory: 4072kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
2 2 2
3 129
129 128
129 131
129 130

output:

b17553fd-ba5a-4140-836c-491f938c515b
OK
24
1 2 0 1
1 2 2 3
1 2 0 2
1 2 1 3
1 2 4 5
1 2 5 4
0 2 4 5
0 2 8 9
0 2 5 4
1 2 10 12
2 2 11 13
2 2 4 5
1 2 10 12
1 2 6 7
1 2 7 6
0 2 6 7
0 2 17 18
0 2 7 6
1 2 19 21
2 2 20 22
2 2 6 7
1 2 19 21
0 2 16 25
1 1 26

result:

ok 

Test #72:

score: 0
Wrong Answer
time: 2ms
memory: 4152kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
101 29 1
8 254
254 255
254 227
254 252
254 196
254 224
254 2958
254 2986
254 226

output:

b17553fd-ba5a-4140-836c-491f938c515b
WA
Too many instructions

result:

wrong answer WA in grader: Too many instructions

Subtask #7:

score: 0
Wrong Answer

Test #101:

score: 0
Wrong Answer
time: 2ms
memory: 4388kb

input:

c2675211-ade0-44b0-8c15-741dd835f3d2
200 200 1
100 524
24804 34853
20956 34628
18830 29184
28919 32573
11364 24911
2226 5624
3715 30838
2206 17143
21162 27531
20198 27242
5007 12724
27160 32586
3535 7307
17015 25466
626 13891
9132 26194
9198 33073
815 7328
6938 21395
9489 30995
10804 21530
14698 394...

output:

b17553fd-ba5a-4140-836c-491f938c515b
WA
Too many instructions

result:

wrong answer WA in grader: Too many instructions

Subtask #8:

score: 0
Skipped

Dependency #1:

0%