提出 #75062188


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
int ans = 0;
void dfs(int cur, vector<vector<int>> &edge, vector<int> &vis)
{
    if (vis[cur] == 0)
    {
        ans++;
        vis[cur] = 1;
    }
    for (auto next : edge[cur])
    {
        if (vis[next] == 1)
        {
            continue;
        }
        dfs(next, edge, vis);
    }
}
int main()
{
    cin.tie(0)->sync_with_stdio(0);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n + 1);
    vector<int> vis(n + 1, 0);
    for (int i = 0; i < m; i++)
    {
        int input, output;
        cin >> input >> output;
        edge[input].push_back(output);
    }
    dfs(1, edge, vis);
    cout << ans;

    return 0;
}

提出情報

提出日時
問題 C - Straw Millionaire
ユーザ RageLog
言語 C++23 (GCC 15.2.0)
得点 300
コード長 728 Byte
結果 AC
実行時間 165 ms
メモリ 35032 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 03_killer_00.txt, 03_killer_01.txt, 03_killer_02.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3484 KiB
00_sample_01.txt AC 1 ms 3484 KiB
00_sample_02.txt AC 1 ms 3644 KiB
01_handmade_00.txt AC 15 ms 5456 KiB
01_handmade_01.txt AC 15 ms 5624 KiB
01_handmade_02.txt AC 15 ms 5056 KiB
01_handmade_03.txt AC 18 ms 5904 KiB
01_handmade_04.txt AC 18 ms 5568 KiB
01_handmade_05.txt AC 157 ms 35032 KiB
01_handmade_06.txt AC 165 ms 35032 KiB
01_handmade_07.txt AC 67 ms 16744 KiB
01_handmade_08.txt AC 63 ms 16896 KiB
01_handmade_09.txt AC 23 ms 10124 KiB
02_random_00.txt AC 71 ms 17876 KiB
02_random_01.txt AC 28 ms 7360 KiB
02_random_02.txt AC 14 ms 4980 KiB
02_random_03.txt AC 34 ms 7784 KiB
02_random_04.txt AC 21 ms 5492 KiB
02_random_05.txt AC 20 ms 5816 KiB
03_killer_00.txt AC 29 ms 18224 KiB
03_killer_01.txt AC 27 ms 18100 KiB
03_killer_02.txt AC 37 ms 29000 KiB