結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-22 22:48:37 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 969 bytes |
| 記録 | |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 71,640 KB |
| 最終ジャッジ日時 | 2026-04-07 08:56:34 |
| 合計ジャッジ時間 | 6,699 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:4:13: error: 'uint64_t' does not name a type
4 | using u64 = uint64_t;
| ^~~~~~~~
main.cpp:3:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
2 | #include <vector>
+++ |+#include <cstdint>
3 | using namespace std;
main.cpp:6:1: error: 'u64' does not name a type
6 | u64 ux = time(NULL);
| ^~~
main.cpp:7:1: error: 'u64' does not name a type
7 | u64 gen() {
| ^~~
main.cpp: In function 'int main()':
main.cpp:25:33: error: 'gen' was not declared in this scope
25 | col[i] = static_cast<int>(gen() % 5);
| ^~~
ソースコード
#include <iostream>
#include <vector>
using namespace std;
using u64 = uint64_t;
u64 ux = time(NULL);
u64 gen() {
ux = ux * 0x5d588b656c078965 + 0x269ec3;
return ux;
}
int main(void) {
int N, M; scanf("%d%d", &N, &M);
vector<vector<int>> G(N, vector<int>());
for(int i=0; i<M; ++i) {
int a, b; scanf("%d%d", &a, &b);
--a, --b;
G[a].push_back(b);
G[b].push_back(a);
}
vector<int> col(N);
vector<vector<bool>> dp;
for(int loop=0; loop<300; ++loop) {
for(int i=0; i<N; ++i) {
col[i] = static_cast<int>(gen() % 5);
}
dp.assign(N, vector<bool>(1<<5, false));
dp[0][0] = true;
for(int S0=0; S0<1<<5; ++S0) {
for(int u=0; u<N; ++u) {
if(!dp[u][S0]) { continue; }
for(int &v : G[u]) {
if(S0 >> col[v] & 1) { continue; }
dp[v][S0|(1<<col[v])] = true;
}
}
}
if(dp[0][(1<<5)-1]) {
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}