結果

問題 No.382 シャイな人たち (2)
ユーザー yosupotyosupot
提出日時 2016-06-18 00:18:50
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,450 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 106,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 00:08:40
合計ジャッジ時間 137,031 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6,031 ms
5,248 KB
testcase_01 AC 6,031 ms
5,248 KB
testcase_02 AC 6,040 ms
5,376 KB
testcase_03 AC 6,036 ms
5,376 KB
testcase_04 AC 6,030 ms
5,376 KB
testcase_05 AC 6,028 ms
5,376 KB
testcase_06 AC 6,032 ms
5,376 KB
testcase_07 AC 6,035 ms
5,376 KB
testcase_08 AC 6,142 ms
5,376 KB
testcase_09 AC 6,036 ms
5,376 KB
testcase_10 AC 6,031 ms
5,376 KB
testcase_11 AC 6,030 ms
5,376 KB
testcase_12 AC 6,037 ms
5,376 KB
testcase_13 AC 6,035 ms
5,376 KB
testcase_14 AC 6,031 ms
5,376 KB
testcase_15 AC 6,030 ms
5,376 KB
testcase_16 AC 6,032 ms
5,376 KB
testcase_17 AC 6,034 ms
5,376 KB
testcase_18 AC 6,038 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 6,039 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

ll nex(ll S) {
    return (S * 12345) % 1000003;
}

const int MN = 130;
int N;
vector<int> g[MN];

int idx[MN];

namespace StopWatch {
    clock_t st;
    bool f = false;
    void start() {
        f = true;
        st = clock();
    }
    int msecs() {
        assert(f);
        return (clock()-st)*1000 / CLOCKS_PER_SEC;
    }
}


void solve() {
/*    printf("N: %d\n", N);
    for (int i = 0; i < N; i++) {
        printf("vec %d:", i);
        for (int d: g[i]) {
            printf("%d ", d);
        }
        printf("\n");
    }*/
    int ans = 0;
    vector<int> ans_p;
    srand(time(NULL));
    iota(idx, idx+N, 0);
    StopWatch::start();
    while (StopWatch::msecs() < 6000) {
        for (int fe = 0; fe < 1000; fe++) {
            random_shuffle(idx, idx+N);
            bool used[N];
            fill_n(used, N, false);
            int co = 0;
            vector<int> res;
            for (int i = 0; i < N; i++) {
                int p = idx[i];
                if (!used[p]) {
                    res.push_back(p+1);
                    co++;
                    for (int d: g[p]) {
                        used[d] = true;
                    }
                }
            }
            if (ans < co) {
                ans = co;
                ans_p = res;
//                printf("ans ref %d\n", co);
            }
        }
    }
    if (ans == N) {
        printf("-1\n");
        return;
    }
    printf("%d\n", ans+1);
    int m = (int)ans_p.size();
    for (int i = 0; i < m; i++) {
        printf("%d", ans_p[i]);
        if (i < m-1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
}

int main() {
    ll S;
    cin >> S;
    S = nex(S);
    N = (S % 120) + 2;
    S = nex(S);
    ll P = S;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            S = nex(S);
            if (S >= P) {
                g[i].push_back(j);
                g[j].push_back(i);
            }
        }
    }

    solve();
    return 0;
}
0