結果
問題 | No.382 シャイな人たち (2) |
ユーザー | yosupot |
提出日時 | 2019-02-12 17:49:50 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 215 ms / 8,000 ms |
コード長 | 4,360 bytes |
コンパイル時間 | 2,217 ms |
コンパイル使用メモリ | 191,096 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 09:43:06 |
合計ジャッジ時間 | 6,523 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 198 ms
6,812 KB |
testcase_01 | AC | 140 ms
6,940 KB |
testcase_02 | AC | 156 ms
6,940 KB |
testcase_03 | AC | 175 ms
6,940 KB |
testcase_04 | AC | 162 ms
6,944 KB |
testcase_05 | AC | 160 ms
6,940 KB |
testcase_06 | AC | 215 ms
6,940 KB |
testcase_07 | AC | 145 ms
6,940 KB |
testcase_08 | AC | 162 ms
6,940 KB |
testcase_09 | AC | 194 ms
6,940 KB |
testcase_10 | AC | 169 ms
6,944 KB |
testcase_11 | AC | 123 ms
6,944 KB |
testcase_12 | AC | 135 ms
6,944 KB |
testcase_13 | AC | 138 ms
6,944 KB |
testcase_14 | AC | 168 ms
6,944 KB |
testcase_15 | AC | 138 ms
6,944 KB |
testcase_16 | AC | 171 ms
6,944 KB |
testcase_17 | AC | 115 ms
6,944 KB |
testcase_18 | AC | 122 ms
6,944 KB |
testcase_19 | AC | 131 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } #define rep(i,N) for(int i=0;i<(int)(N);i++) #define rep1(i,N) for(int i=1;i<=(int)(N);i++) #define fs first #define sc second #define pb push_back #define PB push_back #define MP make_pair #define show(x) cerr << #x << " = " << (x) << endl #define FOR(i, a, b) for(int i=int(a);i<int(b);i++) #define REP(i,b) FOR(i,0,b) #define all(x) x.begin(),x.end() #define ALL(x) x.begin(),x.end() template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; } template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; } template <int N, class E> struct MaxClique { using B = bitset<N>; int n; V<B> g, col_buf; V<int> clique, now; struct P { int id, col, deg; }; void coloring(V<P>& v) { int m = int(v.size()); sort(v.begin(), v.end(), [&](P a, P b) { return a.deg > b.deg; }); for (int i = 0; i < m; i++) { v[i].col = 0; while ((g[v[i].id] & col_buf[v[i].col]).any()) v[i].col++; col_buf[v[i].col].set(v[i].id); } for (int i = 0; i < n; i++) col_buf[i].reset(); sort(v.begin(), v.end(), [&](P a, P b) { return a.col < b.col; }); } void dfs(V<P> rem) { if (clique.size() < now.size()) clique = now; while (!rem.empty()) { auto p = rem.back(); int i = p.id; if (now.size() + p.col + 1 <= clique.size()) break; V<P> nrem; B bs = B(); for (auto q: rem) { if (g[i][q.id]) { nrem.push_back({q.id, -1, 0}); bs.set(q.id); } } for (auto& q: nrem) { q.deg = (bs & g[q.id]).count(); } coloring(nrem); now.push_back(i); dfs(nrem); now.pop_back(); rem.pop_back(); } } MaxClique(VV<E> _g) : n(int(_g.size())), col_buf(n) { g = V<B>(n); V<P> rem; for (int i = 0; i < n; i++) { rem.push_back({i, -1, int(_g[i].size())}); for (auto e: _g[i]) g[i][e.to] = 1; } coloring(rem); dfs(rem); } }; ll nex(ll S) { return (S * 12345) % 1000003; } int main() { struct E { int to; }; cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; ll S; cin >> S; S = nex(S); int n = (S % 120) + 2; VV<E> g(n); 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}); } } } auto st = MaxClique<123, E>(g).clique; int k = int(st.size()); if (n == k) { cout << -1 << endl; return 0; } cout << k + 1 << endl; for (int i = 0; i < k; i++) { cout << st[i] + 1 << (i == k - 1 ? '\n' : ' '); } return 0; } /* int main() { int n, m; cin >> n >> m; VV<int> mp(n, V<int>(n, 1)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; mp[a][b] = mp[b][a] = 0; } struct E { int to; }; VV<E> g(n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (!mp[i][j]) continue; g[i].push_back({j}); g[j].push_back({i}); } } auto cl = MaxClique<E>(g).clique; cout << cl.size() << endl; }*/ /* int main() { int n, d; cin >> n >> d; V<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } struct E { int to; }; VV<E> g(n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if ((a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]) <= d * d) { g[i].push_back({j}); g[j].push_back({i}); } } } auto cl = MaxClique<E>(g).clique; cout << cl.size() << endl; for (int x: cl) cout << x + 1 << " "; cout << endl; }*/