結果

問題 No.382 シャイな人たち (2)
ユーザー 👑 nu50218nu50218
提出日時 2023-03-16 01:02:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,604 bytes
コンパイル時間 3,465 ms
コンパイル使用メモリ 228,752 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 12:46:09
合計ジャッジ時間 180,219 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7,952 ms
4,348 KB
testcase_01 AC 7,953 ms
4,348 KB
testcase_02 AC 7,952 ms
4,348 KB
testcase_03 AC 7,952 ms
4,348 KB
testcase_04 AC 7,953 ms
4,348 KB
testcase_05 AC 7,952 ms
4,348 KB
testcase_06 AC 7,952 ms
4,348 KB
testcase_07 AC 7,952 ms
4,348 KB
testcase_08 AC 7,953 ms
4,348 KB
testcase_09 AC 7,952 ms
4,348 KB
testcase_10 AC 7,952 ms
4,348 KB
testcase_11 AC 7,953 ms
4,348 KB
testcase_12 AC 7,953 ms
4,348 KB
testcase_13 AC 7,952 ms
4,348 KB
testcase_14 AC 7,953 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 7,952 ms
4,348 KB
testcase_17 AC 7,952 ms
4,348 KB
testcase_18 AC 7,953 ms
4,348 KB
testcase_19 AC 7,952 ms
4,348 KB
testcase_20 AC 7,952 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

#include "atcoder/modint.hpp"
using mint = atcoder::static_modint<1000003>;
using namespace std;

int main() {
    auto start = chrono::high_resolution_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int _S;
    cin >> _S;

    mint S = _S;
    S *= 12345;
    int N = S.val() % 120 + 2;
    S *= 12345;
    uint P = S.val();

    bool adj[N][N];
    for (int i = 0; i < N; i++) {
        adj[i][i] = false;
    }

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            S *= 12345;
            adj[i][j] = adj[j][i] = (S.val() >= P);
        }
    }

    vector<int> ans;

    auto rng = mt19937_64(random_device{}());

    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        p[i] = i;
    }

    while (true) {
        auto now = chrono::high_resolution_clock::now();
        auto ms = chrono::duration_cast<chrono::milliseconds>(now - start).count();

        if (ms > 7950) break;

        shuffle(p.begin(), p.end(), rng);

        vector<int> is;

        for (auto&& x : p) {
            bool ok = true;
            for (auto&& y : is) {
                ok &= !adj[x][y];
            }
            if (ok) is.push_back(x);
        }

        if (ans.size() < is.size()) ans.swap(is);
    }

    if ((int)ans.size() == N) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans.size() + 1 << endl;
    for (int i = 0; i < (int)ans.size(); i++) {
        cout << ans[i] + 1 << (i + 1 == (int)ans.size() ? "\n" : " ");
    }
}
0