QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834334#9912. 比赛hhoppitree#0 0ms3872kbC++142.0kb2024-12-27 15:34:092024-12-27 15:34:09

Judging History

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

  • [2024-12-27 15:34:09]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3872kb
  • [2024-12-27 15:34:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 30;

int n;
long long a[N];
vector<long long> res;

void dfs(int x, vector< pair<int, int> > y, vector<long long> z, long long now) {
    int m = y.size();
    for (int i = 1; i < m; ++i) {
        if (y[i].first) z[y[i].first] = min(z[y[i].first], z[i]);
        if (y[i].second) z[y[i].second] = min(z[y[i].second], z[i]);
    }
    for (int i = m - 1; i; --i) {
        z[i] = min(z[i], !y[i].first ? now : z[y[i].first] + z[y[i].second]);
    }
    if ((!y[0].first ? now : z[y[0].first] + z[y[0].second]) <= z[0]) return;
    if (x == n + 1) {
        res.push_back(z[0]);
        return;
    }
    y.push_back({0, 0}), y.push_back({0, 0});
    z.push_back(now), z.push_back(now);
    vector<int> fa(m);
    for (int i = 0; i < m; ++i) {
        fa[y[i].first] = fa[y[i].second] = i;
    }
    fa[0] = -1;
    vector<int> con;
    for (int i = 0; i < m; ++i) {
        if (y[i].first || z[i] <= a[x] || z[0] < a[x]) continue;
        con.push_back(i);
    }
    if (con.size() > 2) {
        if (n == 13) con.resize(3);
        else con = {con[0], con.back()};
    }
    for (auto i : con) {
        y[i].first = m, y[i].second = m + 1;
        for (int j = i; ~j; j = fa[j]) z[j] -= a[x];
        dfs(x + 1, y, z, now);
        y[i].first = y[i].second = 0;
        for (int j = i; ~j; j = fa[j]) z[j] += a[x];
    }
    y.pop_back(), y.pop_back();
    z.pop_back(), z.pop_back();
    dfs(x + 1, y, z, min(now, a[x]));
}

signed main() {
    long long m;
    scanf("%lld%d", &m, &n);
    for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
    dfs(1, {{}}, {m}, m + 1);
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    reverse(res.begin(), res.end());
    printf("%d\n", (int)res.size());
    for (int i = 0; i < (int)res.size(); ++i) {
        printf("%lld%c", m - res[i], " \n"[i + 1 == (int)res.size()]);
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

17
RRBRBRRRBBRRBBBBB

output:

1
0

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

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

input:

30
BRBRRBRBBRBRBBRBBRBBRBBRBBRRBR

output:

1
0

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #13:

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

input:

50
BBBRRRBRRRBBRBRRRBRRRBRRRRRRRBBRRRBBBRRBRRRBBRRRBR

output:

1
0

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #19:

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

input:

200
RBRBRBBRBRBRRBBRBBRBRBBBRBRRBRBRBRRBRRRBRRBRRRRRBRBBRRBBRBBRBBBBRBRBRBBBRRBBRBRRRBRBRBBBBRBRRRBBBBRRRBRBBRBBBRRRRRBRRRRRBRRRRRRRBBRRBRBBRBBRRRBRRRBRRRRBRBRBRRBBRBBRRBRRRRBBRRBRBRBRRRRBBRBRRBBRRBRBBBBR

output:

1
0

result:

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

Subtask #5:

score: 0
Wrong Answer

Test #25:

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

input:

500
RRBBBBRBBBRRRRBRRBBBRBBRRBRBRRBBBBRBRBBBRBBBRBBBBBBRBBRBBBBRRBBBBBBRBBBBBBRBBBBRBRRRRRRBRBBRBBBRBBRRRBRBBRRBBRBBRBBRBRRBBBBBRRRBBBRRBRBRBRRBRBBBRBBBRRRBBRBRBRRRRBBBBBBBRBRRRRRBBBBBBBRBBBRBBRRRBBRRBRRRRRBBBRBRRRRBBBBRBBBRBBBRBBBBRRBRRBRRRBBBBRRBBRRBBBBRRRRBBBBBBBBBRBRRBBRBRBBRRRBBBRBRRRBBBRRBBRBB...

output:

1
0

result:

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

Subtask #6:

score: 0
Wrong Answer

Test #31:

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

input:

3000
RRBBRRBRBBRRRRRBBRBRBRBBBBBRBBRRBBBBBRRBBBRBBBRRRBBRBBBBRRBBRRRRRRRBRRBBRRRRBBRBRRRRRBRRBRRRBRRRRRBBBRBBBRRBBBRRRBRBBBBBRBRBRBRBRBRBBRBRRRRRBBBBBRBBBRRRBBRRRBBRBBRBRBBRRBBRBBBRRBBRRBRBBRRBBBRRBRBRBRRRRRRBBBBRRRBBBRRRBBRRBRBRRBBRRBRRBBBRRRBBRBBBRBRRRRRRBRBBRRBRRBRBRBBBBRRRBBBRBBRBBBBRRRBRRBBBRRB...

output:

1
0

result:

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