結果
| 問題 |
No.1530 Permutation and Popcount
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-06-04 21:23:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| コンパイル時間 | 3,765 ms |
| コンパイル使用メモリ | 253,320 KB |
| 最終ジャッジ日時 | 2025-01-21 23:53:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 WA * 1 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
unsigned long xor128() {
static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
unsigned long t=(x^(x<<11));
x=y; y=z; z=w;
return (w=(w^(w>>19))^(t^(t>>8)));
}
vector<int> X,Y;
int get(int x){
if((__builtin_popcount(x))%2==0)return 1;
else return 0;
}
int get(){
int ret = 0;
rep(i,X.size()){
for(int j=i+1;j<X.size();j++){
ret += get(X[i]*X[j])*2;
}
ret += get(X[i]*X[i]);
}
rep(i,Y.size()){
for(int j=i+1;j<Y.size();j++){
ret -= get(Y[i]*Y[j])*2;
}
ret -= get(Y[i]*Y[i]);
}
return ret;
}
void Print(){
cout<<X.size()<<' '<<Y.size()<<endl;
rep(i,X.size()){
if(i!=0)cout<<' ';
cout<<X[i];
}
cout<<endl;
rep(i,Y.size()){
if(i!=0)cout<<' ';
cout<<Y[i];
}
cout<<endl;
exit(0);
}
int main(){
int N,M;
cin>>N>>M;
rep(i,N)X.push_back(i+1);
rep(_,1000){
int t = get();
if(t == M)Print();
if(t > M){
if(X.size()==0)break;
int x = xor128()%X.size();
Y.push_back(X[x]);
X.erase(X.begin() + x);
}
else{
if(Y.size()==0)break;
int y = xor128()%Y.size();
X.push_back(Y[y]);
Y.erase(Y.begin() + y);
}
}
cout<<-1<<endl;
return 0;
}
沙耶花