結果

問題 No.479 頂点は要らない
ユーザー Konton7Konton7
提出日時 2020-02-05 23:55:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,765 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 207,836 KB
実行使用メモリ 10,612 KB
最終ジャッジ日時 2023-10-24 15:07:07
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 71 ms
10,612 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0