結果
問題 | No.2888 Mamehinata |
ユーザー |
|
提出日時 | 2024-09-13 22:30:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,811 bytes |
コンパイル時間 | 7,375 ms |
コンパイル使用メモリ | 338,420 KB |
実行使用メモリ | 16,772 KB |
最終ジャッジ日時 | 2024-09-13 22:30:59 |
合計ジャッジ時間 | 21,756 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 TLE * 2 -- * 24 |
ソースコード
#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 longrandom_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);rep(i,M) {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);int even_before=-1;int odd_before=-1;bool flag_even=false;bool flag_odd=false;for (int t = 0; t < N; ++t) {if(flag_even&&flag_odd){if(t%2==0)cout << even_before << endl;else cout<<odd_before<<endl;continue;}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;if(t%2==0&&even_before==cnt){flag_even=true;}if(t%2==1&&odd_before==cnt){flag_odd=true;}if(t%2==0)even_before=cnt;else odd_before=cnt;}return 0;}