QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#818583#8811. Heat Strokemakrav7 69ms3788kbC++202.6kb2024-12-17 22:25:492024-12-17 22:25:50

Judging History

This is the latest submission verdict.

  • [2024-12-17 22:25:50]
  • Judged
  • Verdict: 7
  • Time: 69ms
  • Memory: 3788kb
  • [2024-12-17 22:25:49]
  • Submitted

answer

#include <bits/stdc++.h>
#include <cassert>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define ff first
#define sc second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
void shuf(vector<T>& a) {
    for (int i = 1; i < sz(a); i++) swap(a[i], a[rnd() % (i + 1)]);
}

void solve() {
    int l; cin >> l;
    vector<int> c(l);
    for (int i = 0; i < l; i++) cin >> c[i];
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<vector<int>> guys(l - 1);
    for (int i = 0; i < n; i++) guys[a[i] - 1].pb(i);

    int ans = 0;
    for (int mask = 1; mask < (1 << n); mask++) {
        //if ((mask >> 0) & 1) continue;
        vector<int> time(l, 1e9);
        for (int i = 0; i < n; i++) {
            if ((mask >> i) & 1) {
                time[a[i] - 1] = min(time[a[i] - 1], i - 1);
                time[a[i]] = min(time[a[i]], i - 1);
            }
        }
        vector<int> used(n);
        bool good = true;
        if (time[0] != 1e9) {
            int mg = -1;
            for (int guy : guys[0]) {
                if (guy <= time[0] && !((mask >> guy) & 1)) mg = guy;
            }
            if (mg == -1) {
                good = false;
            }
            else used[mg] = 1;
        }
        vector<bool> bitt(n);
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            bitt[i] = ((mask >> i) & 1);
            cnt += bitt[i];
        }
        for (int i = 1; i < l; i++) {
            if (time[i] == 1e9) continue;
            bool found = false;
            for (int guy : guys[i - 1]) {
                if (guy <= time[i] && !used[guy] && !bitt[guy]) {
                    found = true;
                }
            }
            if (!found) {
                if (i == l - 1) {
                    good = false; break;
                }
                int mg = -1;
                for (int guy : guys[i]) {
                    if (guy <= time[i] && !bitt[guy]) mg = guy;
                }
                if (mg == -1) {
                    good = false;
                } else used[mg] = 1;
            }
        }
        if (good) ans = max(ans, cnt);
    }
    
    cout << ans << '\n';
}

signed main() {
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        ios::sync_with_stdio(false);
        cin.tie(0); cout.tie(0);
    #endif

    while (tt--) {
        solve();
    }

    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

2
0 0
1
1

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 7
Accepted

Test #33:

score: 7
Accepted
time: 0ms
memory: 3572kb

input:

3
1 1 1
3
1 2 1

output:

1

result:

ok single line: '1'

Test #34:

score: 7
Accepted
time: 0ms
memory: 3788kb

input:

3
1 1 1
3
2 1 2

output:

1

result:

ok single line: '1'

Test #35:

score: 7
Accepted
time: 0ms
memory: 3576kb

input:

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

output:

3

result:

ok single line: '3'

Test #36:

score: 7
Accepted
time: 1ms
memory: 3628kb

input:

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

output:

4

result:

ok single line: '4'

Test #37:

score: 7
Accepted
time: 2ms
memory: 3584kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13
13 17 13 9 15 4 12 11 12 7 5 15 1

output:

1

result:

ok single line: '1'

Test #38:

score: 7
Accepted
time: 8ms
memory: 3556kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15
17 12 6 3 15 17 3 10 6 12 15 17 11 12 14

output:

3

result:

ok single line: '3'

Test #39:

score: 7
Accepted
time: 16ms
memory: 3524kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16
16 11 13 10 5 3 10 6 13 16 16 2 14 9 9 3

output:

4

result:

ok single line: '4'

Test #40:

score: 7
Accepted
time: 30ms
memory: 3604kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
17
12 5 4 1 10 6 8 8 16 6 12 14 7 14 17 12 9

output:

4

result:

ok single line: '4'

Test #41:

score: 7
Accepted
time: 65ms
memory: 3584kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
14 9 3 16 9 2 2 9 4 10 12 17 13 10 10 10 3 11

output:

7

result:

ok single line: '7'

Test #42:

score: 7
Accepted
time: 65ms
memory: 3504kb

input:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
15 9 6 3 13 9 13 16 7 5 8 1 1 9 9 15 16 1

output:

5

result:

ok single line: '5'

Test #43:

score: 7
Accepted
time: 66ms
memory: 3572kb

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
13 4 8 8 13 8 1 15 3 6 4 8 6 4 12 9 15 14

output:

5

result:

ok single line: '5'

Test #44:

score: 7
Accepted
time: 64ms
memory: 3604kb

input:

15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 10 3 3 9 6 4 8 3 12 12 11 7 14 6 5 3 3

output:

6

result:

ok single line: '6'

Test #45:

score: 7
Accepted
time: 59ms
memory: 3552kb

input:

13
1 1 1 1 1 1 1 1 1 1 1 1 1
18
11 5 4 8 12 2 1 3 8 8 9 4 12 7 12 3 6 6

output:

7

result:

ok single line: '7'

Test #46:

score: 7
Accepted
time: 65ms
memory: 3584kb

input:

13
1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 2 1 3 4 3 5 6 5 7 8 7 9 10 9 11 12 11

output:

6

result:

ok single line: '6'

Test #47:

score: 7
Accepted
time: 66ms
memory: 3728kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 5 7 11 13 17 2 4 8 10 14 16 1 5 7 11 13 17

output:

6

result:

ok single line: '6'

Test #48:

score: 7
Accepted
time: 8ms
memory: 3600kb

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15
1 3 2 4 6 5 7 9 8 10 12 11 13 15 14

output:

5

result:

ok single line: '5'

Test #49:

score: 7
Accepted
time: 69ms
memory: 3512kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
18
1 1 2 4 5 4 7 8 8 11 10 10 14 13 14 17 17 16

output:

4

result:

ok single line: '4'

Test #50:

score: 7
Accepted
time: 1ms
memory: 3788kb

input:

16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12
1 2 3 5 7 6 10 9 11 15 14 13

output:

1

result:

ok single line: '1'

Subtask #3:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #51:

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

input:

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

output:

0

result:

wrong answer 1st lines differ - expected: '15', found: '0'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #1:

0%