QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304425#8004. Bit Componentucup-team228#WA 0ms3804kbC++172.7kb2024-01-13 19:40:452024-01-13 19:40:46

Judging History

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

  • [2024-01-13 19:40:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-01-13 19:40:45]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct DSU {
    static const int N = 2e5 + 10;
    int Parent[N], Rank[N], Size[N], cnt;
    void init(int n) {
        for (int i = 1; i <= n; i++) {
            Parent[i] = i, Rank[i] = 0, Size[i] = 1;
        }
        cnt = n;
    }
    int find(int v) {
        if (Parent[v] == v) return v;
        else return Parent[v] = find(Parent[v]);
    }
    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;
        if (Rank[u] < Rank[v]) swap(u, v);
        if (Rank[v] == Rank[u]) Rank[u]++;
        Parent[v] = u, cnt--;
        Size[u] += Size[v];
    }
} dsu;

bool getbit(int mask, int bit) {
    return mask & (1 << bit);
}

bool check(int n, int b, const vector<int>& a) {
    int tot = 0;
    for (int i = 0; i < n; i++) {
        tot += __builtin_popcount(a[i]);
    }
    dsu.init(n * b);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j + 1 < b; j++) {
            if (getbit(a[i], j) && getbit(a[i], j + 1)) {
                dsu.unite(i * b + j + 1, i * b + j + 2);
            }
        }
    }
    for (int i = 0; i + 1 < n; i++) {
        for (int j = 0; j < b; j++) {
            if (getbit(a[i], j) && getbit(a[i + 1], j)) {
                dsu.unite(i * b + j + 1, (i + 1) * b + j + 1);
            }
        }
    }
    return n * b - tot + 1 == dsu.cnt;
}

void foo() {
    const int n = 9;
    const int b = 4;
    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    do {
        if (check(n, b, a)) {
            cout << "YES\n";
            for (int x : a) {
                cout << x << " " << bitset<b>(x) << "\n";
            }
            return;
        }
    } while (next_permutation(a.begin(), a.end()));
    cout << "NO\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    // foo();
    int n;
    cin >> n;
    if (__builtin_popcount(n + 1) == 1) {
        cout << "YES\n";
        vector<int> ans = {1};
        int b = 0;
        while (ans.size() < n) {
            b++;
            vector<int> tmp = ans;
            reverse(tmp.begin(), tmp.end());
            for (int x : tmp) {
                ans.push_back(x | (1 << b));
            }
            ans.push_back(1 << b);
        }
        for (int x : ans) {
            cout << x << " ";
        }
        cout << "\n";
        // assert(check(n, 20, ans));
    } else {
        cout << "NO\n";
    }

#ifdef LOCAL
    cout << "\nTime elapsed: " << double(clock()) / CLOCKS_PER_SEC << " s.\n";
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

input:

1

output:

YES
1 

result:

ok answer is 1

Test #2:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2 

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

4

output:

NO

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5

output:

NO

result:

ok answer is 0

Test #6:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

6

output:

NO

result:

ok answer is 0

Test #7:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

7

output:

YES
1 3 2 6 7 5 4 

result:

ok answer is 1

Test #8:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

8

output:

NO

result:

ok answer is 0

Test #9:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

9

output:

NO

result:

ok answer is 0

Test #10:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

10

output:

NO

result:

ok answer is 0

Test #11:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

11

output:

NO

result:

ok answer is 0

Test #12:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

NO

result:

wrong answer Jury has the answer, participant doesn't