結果
問題 |
No.2888 Mamehinata
|
ユーザー |
|
提出日時 | 2024-09-13 22:25:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,348 bytes |
コンパイル時間 | 7,324 ms |
コンパイル使用メモリ | 337,140 KB |
実行使用メモリ | 14,492 KB |
最終ジャッジ日時 | 2024-09-13 22:25:57 |
合計ジャッジ時間 | 13,964 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 2 -- * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using mint = modint998244353; #define ull unsigned long long random_device rnd; mt19937 mt(rnd()); int RandInt(int a, int b) { return a + mt() % (b - a + 1); } int main() { int N, M; cin >> N >> M; vector<vector<int>> to(N); for (int i = 0; i < M; ++i) { int u, v; cin >> u >> v; u--; v--; to[u].push_back(v); to[v].push_back(u); } vector<int> color(N, 0); // 0:白, 1:黒 color[0] = 1; vector<int> black_cnt(N); for (int t = 0; t < N; ++t) { set<int> red; rep(u,N) { if (color[u] == 0) { for (int v : to[u]) { if (color[v] == 1) { red.insert(u); break; } } } } rep(u,N) { if (color[u] == 1) { color[u] = 0; } } for (int u : red) { color[u] = 1; } int cnt = 0; rep(u,N) { if (color[u] == 1) { cnt++; } } black_cnt[t] = cnt; cout << cnt << endl; } return 0; }