QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304857#8004. Bit Componentucup-team1134#WA 3ms6276kbC++233.1kb2024-01-14 04:28:232024-01-14 04:28:23

Judging History

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

  • [2024-01-14 04:28:23]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6276kb
  • [2024-01-14 04:28:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

//Union Find


struct UF{
    int n;
    vector<int> par,size,edge;
    
    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        edge.assign(n,0);
        
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }
    
    int root(int a){
        if(par[a]==a) return a;
        else return par[a]=root(par[a]);
    }
    
    void unite(int a,int b){
        edge[root(a)]++;
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            edge[root(a)]+=edge[root(b)];
            par[root(b)]=root(a);
        }
    }
    
    bool check(int a,int b){
        return root(a)==root(b);
    }
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    if(N==1){
        cout<<"YES\n";
        cout<<1<<"\n";
        return 0;
    }
    vector<int> X={1};
    for(int n=2;n<=400000;n*=2){
        vector<int> Y=X;reverse(all(Y));
        for(int x:Y){
            X.push_back(x|n);
        }
        X.push_back(n);
        
        if(si(X)==N){
            cout<<"YES\n";
            for(int i=0;i<N;i++){
                if(i) cout<<" ";
                cout<<X[i];
            }
            cout<<"\n";
            return 0;
        }
    }
    
    cout<<"NO\n";
    
    /*
    for(int N=7;N<=7;N++){
        vector<int> P(N);iota(all(P),1);
        do{
            vector<vector<int>> S(N,vector<int>(4));
            for(int i=0;i<N;i++){
                for(int j=0;j<4;j++){
                    if(P[i]&(1<<j)) S[i][j]=1;
                }
            }
            UF uf;uf.init(N*4);
            for(int i=0;i<N;i++){
                for(int j=0;j<4;j++){
                    if(i+1<N){
                        if(S[i][j]&&S[i+1][j]) uf.unite(i*4+j,(i+1)*4+j);
                    }
                    if(j+1<4){
                        if(S[i][j]&&S[i][j+1]) uf.unite(i*4+j,i*4+(j+1));
                    }
                }
            }
            set<int> RO;
            for(int i=0;i<N;i++){
                for(int j=0;j<4;j++){
                    if(S[i][j]){
                        RO.insert(uf.root(i*4+j));
                    }
                }
            }
            if(si(RO)==1){
                for(int i=0;i<N;i++){
                    for(int j=3;j>=0;j--){
                        cout<<S[i][j];
                    }
                    cout<<endl;
                }
                cout<<endl;
            }
        }while(next_permutation(all(P)));
    }
     */
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

1

output:

YES
1

result:

ok answer is 1

Test #2:

score: 0
Accepted
time: 3ms
memory: 6180kb

input:

2

output:

NO

result:

ok answer is 0

Test #3:

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

input:

3

output:

YES
1 3 2

result:

ok answer is 1

Test #4:

score: 0
Accepted
time: 3ms
memory: 6276kb

input:

4

output:

NO

result:

ok answer is 0

Test #5:

score: 0
Accepted
time: 3ms
memory: 6188kb

input:

5

output:

NO

result:

ok answer is 0

Test #6:

score: 0
Accepted
time: 3ms
memory: 6268kb

input:

6

output:

NO

result:

ok answer is 0

Test #7:

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

input:

7

output:

YES
1 3 2 6 7 5 4

result:

ok answer is 1

Test #8:

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

input:

8

output:

NO

result:

ok answer is 0

Test #9:

score: 0
Accepted
time: 3ms
memory: 6276kb

input:

9

output:

NO

result:

ok answer is 0

Test #10:

score: 0
Accepted
time: 3ms
memory: 6224kb

input:

10

output:

NO

result:

ok answer is 0

Test #11:

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

input:

11

output:

NO

result:

ok answer is 0

Test #12:

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

input:

12

output:

NO

result:

ok answer is 0

Test #13:

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

input:

13

output:

NO

result:

wrong answer Jury has the answer, participant doesn't