結果
| 問題 |
No.479 頂点は要らない
|
| コンテスト | |
| ユーザー |
Konton7
|
| 提出日時 | 2020-02-05 23:55:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,765 bytes |
| コンパイル時間 | 2,568 ms |
| コンパイル使用メモリ | 199,636 KB |
| 最終ジャッジ日時 | 2025-01-08 22:25:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main()
{
#ifdef DEBUG
cout << "DEBUG MODE" << endl;
ifstream in("input.txt"); //for debug
cin.rdbuf(in.rdbuf()); //for debug
#endif
int n, m, a, b, d;
cin >> n >> m;
vector<int> connect[n], search, new_search;
string ans;
int depth[n];
fill(depth, depth + n, 0);
rep(i, m)
{
cin >> a >> b;
connect[a].push_back(b);
connect[b].push_back(a);
}
for (int k = n - 1; k >= 0; k--)
{
if (depth[k] == 0)
{
search.push_back(k);
d = 1;
while (!search.empty())
{
for (auto i : search)
depth[i] = d;
for (auto i : search)
{
for (auto j : connect[i])
{
if (depth[j] == 0)
new_search.push_back(j);
}
}
search.clear();
search = new_search;
new_search.clear();
d++;
}
}
}
#ifdef DEBUG
for (auto z : depth)
cout << z << " ";
cout << endl;
#endif
depth[0] = 0;
d = 0;
rep(i, n)
{
if (depth[i] % 2 == 1)
{
ans += '0';
}
else
{
ans += '1';
d = i;
}
}
ans = ans.substr(0, d + 1);
reverse(ans.begin(), ans.end());
cout << ans << endl;
return 0;
}
Konton7