結果

問題 No.382 シャイな人たち (2)
ユーザー fumofumofunifumofumofuni
提出日時 2022-09-10 18:11:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,274 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 209,516 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 22:28:17
合計ジャッジ時間 112,943 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5,169 ms
4,376 KB
testcase_01 AC 5,180 ms
4,380 KB
testcase_02 AC 5,180 ms
4,376 KB
testcase_03 AC 5,206 ms
4,380 KB
testcase_04 AC 5,173 ms
4,376 KB
testcase_05 AC 5,195 ms
4,380 KB
testcase_06 AC 5,074 ms
4,376 KB
testcase_07 AC 5,195 ms
4,376 KB
testcase_08 AC 5,145 ms
4,376 KB
testcase_09 AC 5,236 ms
4,376 KB
testcase_10 AC 5,151 ms
4,376 KB
testcase_11 AC 5,013 ms
4,380 KB
testcase_12 AC 5,235 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 5,188 ms
4,380 KB
testcase_15 AC 5,260 ms
4,376 KB
testcase_16 AC 5,182 ms
4,376 KB
testcase_17 AC 5,167 ms
4,376 KB
testcase_18 AC 5,184 ms
4,376 KB
testcase_19 AC 5,144 ms
4,380 KB
testcase_20 AC 131 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={0,1,0,-1,1,1,-1,-1,0};
const ll dx[9]={1,0,-1,0,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using bs=bitset<128>;
vector<int> maxindependent(vector<bs> mat,int trial=3000000){
    int n=mat.size();
    int ans=0;
    bs cand;
    vector<int> order(n);rep(i,n)order[i]=i;
    mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
    while(trial--){
        shuffle(all(order),mt);
        bs used;
        int ret=0;
        rep(i,n){
            if((used&mat[order[i]]).any())continue;
            used[order[i]]=1;ret++;
        }
        if(ans<ret){
            ans=ret;
            cand=used;
        }
    }
    vector<int> lc;
    for(int i=0;i<n;i++){
        if(cand[i])lc.emplace_back(i);
    }
    return lc;
}
int main(){
    ll s;cin >> s;
    ll mod=1000003;
    s=s*12345%mod;
    ll n=s%120+2;
    s=s*12345%mod;
    ll p=s;
    vector<bs> mat(n);
    rep(i,n){
        repl(j,i+1,n){
            s=(s*12345)%mod;
            if(s>=p){
                mat[i][j]=1;
                mat[j][i]=1;
            }
        }
    }
    auto f=maxindependent(mat);
    if(f.size()==n){
        cout << -1 << endl;return 0;
    }
    cout << f.size()+1 << endl;
    rep(i,f.size()){
        if(i)cout << " ";
        cout << f[i]+1;
    }
    cout << endl;
}
0