QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#794371#9802. Light Up the Griducup-team3584#WA 20ms3668kbC++231.9kb2024-11-30 13:56:332024-11-30 13:56:37

Judging History

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

  • [2024-11-30 13:56:37]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:3668kb
  • [2024-11-30 13:56:33]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    vector<ll> a(9);
    cin >> a[0];
    a[1] = a[2] = a[3] = a[0];
    cin >> a[4];
    a[5] = a[4];
    cin >> a[6];
    a[7] = a[6];
    cin >> a[8];

    vector<ll> dp(1 << 16, 2e9);
    vector<int> uo = {1, 2, 4, 8, 3, 12, 5, 10, 15};
    dp[0] = 0;
    for (int i = 0; i < 1 << 16; ++i) {
        for (int j = 0; j < 9; ++j) {
            int bit = 0;
            for (int k = 0; k < 15; ++k) {
                if (1 << k & i) {
                    bit |= 1 << (k ^ uo[j]);
                }
            }
            dp[bit] = min(dp[bit], dp[i] + a[j]);
            bit |= 1 << (15 ^ uo[j]);
            dp[bit] = min(dp[bit], dp[i] + a[j]);
        }
    }
    //    for (int i = dp.size() - 1; i > 0; --i) {
    //        for (int j = 0; j < 16; ++j) {
    //            if ((1 << j) & i) {
    //                dp[i ^ (1 << j)] = min(dp[i ^ (1 << j)], dp[i]);
    //            }
    //        }
    //    }
    while (q--) {
        int n;
        cin >> n;
        int bit = 0;
        for (int i = 0; i < n; ++i) {
            char c;
            int num = 0;
            for (int j = 0; j < 4; ++j) {
                cin >> c;
                if (c == '1') {
                    num |= 1 << j;
                }
            }
            bit |= (1 << num);
        }
        cout << dp[bit] << '\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 13ms
memory: 3616kb

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

1121
2

result:

ok 2 number(s): "1121 2"

Test #2:

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

input:

2 1 1 1 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

5
2

result:

ok 2 number(s): "5 2"

Test #3:

score: 0
Accepted
time: 13ms
memory: 3668kb

input:

1 1000000 1000000 1000000 1000000
1
11
11

output:

2000000

result:

ok 1 number(s): "2000000"

Test #4:

score: -100
Wrong Answer
time: 20ms
memory: 3612kb

input:

10000 8 2 7 8
8
00
01

00
11

00
10

11
11

10
10

01
10

01
00

10
11
8
11
01

11
00

01
10

11
11

00
01

01
01

01
00

11
10
9
00
00

01
01

10
11

00
01

11
10

11
00

11
11

00
11

01
10
9
11
11

10
00

11
00

11
01

00
10

01
11

00
01

01
01

10
01
11
00
01

01
01

10
10

00
11

11
11

11
10
...

output:

46
38
42
48
60
43
50
65
55
54
50
59
55
53
42
39
39
52
76
59
47
44
56
44
37
52
55
62
35
45
39
58
45
37
57
54
59
44
46
39
42
61
46
40
75
48
45
50
47
52
56
46
61
59
48
54
63
58
47
46
55
55
44
49
34
52
41
45
62
63
47
43
40
49
46
63
50
57
56
50
36
61
44
44
48
49
56
49
49
45
52
60
56
53
61
37
48
61
36
44
...

result:

wrong answer 1st numbers differ - expected: '34', found: '46'