QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490319#5742. Garbage Disposalucup-team1525#WA 0ms3796kbC++201.5kb2024-07-25 14:35:302024-07-25 14:35:30

Judging History

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

  • [2024-07-25 14:35:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-07-25 14:35:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 25;
const int mod = 1e9 + 9;

int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
int mul(ll x, ll y) {return x * y % mod;}
int ksm(ll x, int tp, int s = 1) {
    for (; tp; x = x * x % mod, tp >>= 1)
        if (tp & 1)
            s = x * s % mod;
    return s;
}

int n;
ll b[N];

vector<int> p[N];

void brute_search() {
    cin >> n;
    for (int s = 0; s < (1 << ((n + 1) / 2)); s++) {
        for (int i = 1; i <= n; i += 2) {
            if ((s >> (i - 1)) & 1) b[i] = 1;
            else b[i] = -1;
            b[i + 1] = -b[i];
        }
        p[0].resize(2), p[0][1] = 1;
        p[1].resize(3), p[1][0] = sub(0, b[1]), p[1][2] = 1;
        bool flag = true;
        for (int i = 2; i <= n; i++) {
            p[i].resize(i + 2);
            for (int j = 0; j < i + 1; j++) p[i][j + 1] = p[i - 1][j];
            for (int j = 0; j < i; j++) p[i][j] = sub(p[i][j], mul(b[i], p[i - 2][j]));
            for (int j = 0; j < i + 2; j++) {
                if (p[i][j] == 1 || p[i][j] == mod - 1 || p[i][j] == 0) continue;
                flag = false;
                break;
            }
            if (!flag) break;
        }
        if (flag) {
            for (int i = 1; i <= n; i++)
                printf("%lld%c", b[i], " \n"[i == n]);
        }
    }
}

int main() {
    brute_search();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1 5
10 13
100 100

output:

-1 1 -1

result:

wrong answer Jury found answer but participant didn't (test case 1)