結果
| 問題 |
No.382 シャイな人たち (2)
|
| コンテスト | |
| ユーザー |
Min_25
|
| 提出日時 | 2016-06-19 10:50:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,414 bytes |
| コンパイル時間 | 854 ms |
| コンパイル使用メモリ | 77,152 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 05:20:00 |
| 合計ジャッジ時間 | 35,592 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 1 |
ソースコード
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <tuple>
#define _fetch(_1, _2, _3, _4, name, ...) name
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c))
#define rep(...) _fetch(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__)
using namespace std;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f80 = long double;
using u128 = __uint128_t;
const u32 N_MAX = 120;
u128 edges[N_MAX + 1];
u128 bits[N_MAX + 1];
struct Rand {
Rand(u32 seed) : x(seed) {}
u32 next() { return x = u64(x) * 12345 % 1000003; }
u32 x;
};
int gene_graph(int S) {
auto gene = Rand(S);
int N = gene.next() % N_MAX + 2;
int P = gene.next();
rep(i, N) edges[i] = bits[i];
rep(i, N) rep(j, i + 1, N) {
int X = gene.next();
if (X >= P) {
edges[i] |= u128(1) << j;
edges[j] |= u128(1) << i;
}
}
return N;
}
struct xor64 {
xor64(u64 seed) : x(seed) {}
u64 next() {
x ^= x << 13; x ^= x >> 7;
return x ^= x << 17;
}
u64 x;
};
vector<int> rmis(int N) {
int perms[N_MAX + 1];
int ret[N_MAX + 1], t[N_MAX + 1];
int max_c = 0;
auto gene = xor64(rand());
const auto G = (u128(1) << N) - 1;
rep(i, N) perms[i] = i;
rep(_, 1000000) {
u128 V = 0;
int c = 0;
for (int i = N - 1; i >= 0; --i) {
swap(perms[gene.next() % (i + 1)], perms[i]);
int v = perms[i];
if (V & bits[v]) continue;
V |= edges[v];
t[c++] = v;
if (V == G) break;
}
if (c > max_c) {
max_c = c;
copy(t, t + c, ret);
}
}
return vector<int>(ret, ret + max_c);
}
void solve() {
srand(time(nullptr));
bits[0] = 1;
rep(i, 1, N_MAX + 1) bits[i] = bits[i - 1] << 1;
int S;
while (~scanf("%d", &S)) {
int N = gene_graph(S);
auto ans = rmis(N);
if (int(ans.size()) == N) {
puts("-1");
} else {
printf("%u\n", int(ans.size() + 1));
printf("%u", ans[0] + 1);
rep(i, 1, ans.size()) printf(" %u", ans[i] + 1);
puts("");
}
}
}
int main() {
clock_t beg = clock();
solve();
clock_t end = clock();
fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
return 0;
}
Min_25