QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404148#6317. XOR Tree Pathcomeintocalm#WA 6ms7012kbC++141.6kb2024-05-03 13:52:192024-05-03 13:52:20

Judging History

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

  • [2024-05-03 13:52:20]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:7012kb
  • [2024-05-03 13:52:19]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

const int MAXN = 1e5 + 5, N = 9999;
int n, m;
int f[105][N + 5];

vector<int> vec[N + 5];

int cnt[N + 5];
int p[10], mp[10];
int main() {
    int i,j,k;
    int x, y, z;
    cin >> n >> m;
    for (i = 0; i <= n; ++i)
        for (j = 0; j <= N; ++j)
            f[i][j] = -1e9;
    for (i = 0; i <= N; ++i) {
        std::vector<int> num, ids;
        int tmp = i, j = 0;
        while (tmp > 0) {
            num.emplace_back(tmp % 10);
            ids.emplace_back(j++);
            tmp /= 10;
        }
        do {
            int qwq = 0;
            for (auto &id: ids) {
                qwq = 10 * qwq + num[id];
            }
            vec[i].emplace_back(qwq);
        } while (std::next_permutation(ids.begin(), ids.end()));
    }
    //for (int i = 0; i <= N; ++i) {
    //    std::cout << i << ": " << std::endl;
    //    for (auto &x: vec[i]) {
    //        std::cout << x << ' ';
    //    }
    //    std::cout << std::endl;
    //}

    for (k = 0; k < vec[m].size(); ++k)
        f[0][ vec[m][k] ] = 0;
    for (i = 1; i <= n; ++i) {
        cin >> x;
        for (j = x; j <= N; ++j)
            f[i][j - x] = max (f[i][j - x], f[i - 1][j] + 1);
        for (j = 0; j <= N; ++j)
            f[i][j] = max (f[i][j], f[i - 1][j]);
        for (j = 0; j <= N; ++j)
            for (k = 0; k < vec[j].size(); ++k)
                f[i][j] = max (f[i][j], f[i][ vec[j][k] ]);
    }
    int ans = 0;
    for (i = 0; i <= N; ++i)
        ans = max (ans, f[n][i]);
    cout << ans << std::endl;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 7012kb

input:

5
1 0 0 1 0
1 2
1 3
3 4
3 5

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: 0
Accepted
time: 5ms
memory: 6932kb

input:

6
1 1 0 0 1 0
3 1
2 5
1 2
4 1
2 6

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: -100
Wrong Answer
time: 6ms
memory: 5436kb

input:

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

output:

9

result:

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