結果

問題 No.479 頂点は要らない
ユーザー snrnsidysnrnsidy
提出日時 2021-05-25 04:46:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 1,500 ms
コード長 1,054 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 200,808 KB
実行使用メモリ 9,196 KB
最終ジャッジ日時 2024-04-21 14:19:32
合計ジャッジ時間 5,036 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,760 KB
testcase_01 AC 3 ms
5,760 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 4 ms
5,760 KB
testcase_04 AC 4 ms
5,760 KB
testcase_05 AC 4 ms
5,760 KB
testcase_06 AC 4 ms
5,888 KB
testcase_07 AC 4 ms
5,888 KB
testcase_08 AC 3 ms
5,760 KB
testcase_09 AC 4 ms
5,888 KB
testcase_10 AC 5 ms
5,760 KB
testcase_11 AC 5 ms
5,888 KB
testcase_12 AC 4 ms
5,760 KB
testcase_13 AC 4 ms
5,760 KB
testcase_14 AC 4 ms
5,760 KB
testcase_15 AC 5 ms
5,632 KB
testcase_16 AC 4 ms
5,888 KB
testcase_17 AC 4 ms
5,888 KB
testcase_18 AC 4 ms
5,760 KB
testcase_19 AC 4 ms
5,888 KB
testcase_20 AC 4 ms
5,888 KB
testcase_21 AC 4 ms
5,760 KB
testcase_22 AC 4 ms
5,888 KB
testcase_23 AC 4 ms
5,888 KB
testcase_24 AC 4 ms
5,760 KB
testcase_25 AC 5 ms
6,016 KB
testcase_26 AC 51 ms
9,088 KB
testcase_27 AC 50 ms
8,960 KB
testcase_28 AC 37 ms
9,196 KB
testcase_29 AC 36 ms
7,680 KB
testcase_30 AC 36 ms
7,808 KB
testcase_31 AC 36 ms
7,680 KB
testcase_32 AC 36 ms
7,808 KB
testcase_33 AC 35 ms
8,064 KB
testcase_34 AC 40 ms
7,936 KB
testcase_35 AC 36 ms
7,424 KB
testcase_36 AC 22 ms
6,528 KB
testcase_37 AC 41 ms
7,936 KB
testcase_38 AC 36 ms
7,552 KB
testcase_39 AC 26 ms
7,168 KB
testcase_40 AC 32 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <int> adj[100001];
bool check[100001];
int n, m, a, b;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    memset(check, false, sizeof(check));

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 0; i < n; i++)
    {
        sort(adj[i].rbegin(), adj[i].rend());
    }

    for (int i = n - 2; i >= 0; i--)
    {
        bool flag = false;
        for (auto it : adj[i])
        {
            if (it < i)
            {
                break;
            }
            if (!check[it])
            {
                flag = true;
                break;
            }
        }
        check[i] = flag;
    }

    int idx = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (check[i])
        {
            idx = i;
            break;
        }
    }

    for (int i = idx; i >= 0; i--)
    {
        cout << check[i];
    }
    cout << '\n';

    return 0;
}
0