結果

問題 No.1530 Permutation and Popcount
ユーザー chocoruskchocorusk
提出日時 2021-06-05 01:02:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 3,358 ms
コンパイル使用メモリ 188,172 KB
実行使用メモリ 108,408 KB
最終ジャッジ日時 2023-08-12 22:10:03
合計ジャッジ時間 9,184 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,384 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
5,468 KB
testcase_07 AC 2 ms
5,540 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 25 ms
73,048 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 5 ms
17,760 KB
testcase_17 WA -
testcase_18 AC 21 ms
66,852 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 30 ms
83,164 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 50 ms
108,128 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 51 ms
108,288 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 51 ms
107,832 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int dp[303][90900];
int main()
{
    int n, m;
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(popcount(i*j)%2==0) m++;
        }
    }
    if(m%2==1){
        cout<<-1<<endl;
        return 0;
    }
    m/=2;
    int c[303]={};
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(popcount(i*j)%2==0) c[i-1]++;
        }
    }
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=n*n; j++){
            if(dp[i][j]==0) continue;
            dp[i+1][j]=1;
            dp[i+1][j+c[i]]=2;
        }
    }
    if(dp[n][m]==0){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> v[2];
    for(int i=n-1; i>=0; i--){
        v[dp[i+1][m]-1].push_back(i+1);
        if(dp[i+1][m]==2){
            m-=c[i];
        }
    }
    cout<<v[0].size()<<" "<<v[1].size()<<endl;
    for(auto x:v[0]) cout<<x<<" ";
    cout<<endl;
    for(auto x:v[1]) cout<<x<<" ";
    cout<<endl;
    return 0;
}
0