提出 #75105295


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define pb push_back

template<class T> inline bool chmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int MOD = 1e9 + 7;

void solve() {
    int n,m;cin>>n>>m;
    vector<vector<int>> adj(n+1);
    for(int i=0;i<m;i++){
        int u,v;cin>>u>>v;
        adj[u].pb(v);
    }
    vector<bool> vis(n+1,false);
    int ans=0;
    auto dfs=[&](auto& self,int node)->void{
        vis[node]=true;
        ans++;
        for(int v:adj[node]){
            if(!vis[v]){
                self(self,v);
            }
        }
    };
    dfs(dfs,1);
    cout<<ans<<'\n';
    
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    //cin>>tt;
    while (tt--) {
        solve();
    }

    return 0;
}

提出情報

提出日時
問題 C - Straw Millionaire
ユーザ lavi3
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1072 Byte
結果 AC
実行時間 110 ms
メモリ 26584 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 3620 KiB
00_sample_01.txt AC 1 ms 3560 KiB
00_sample_02.txt AC 1 ms 3536 KiB
01_handmade_00.txt AC 16 ms 5392 KiB
01_handmade_01.txt AC 16 ms 5480 KiB
01_handmade_02.txt AC 16 ms 5048 KiB
01_handmade_03.txt AC 19 ms 5860 KiB
01_handmade_04.txt AC 21 ms 5532 KiB
01_handmade_05.txt AC 110 ms 26584 KiB
01_handmade_06.txt AC 98 ms 26584 KiB
01_handmade_07.txt AC 57 ms 13760 KiB
01_handmade_08.txt AC 56 ms 13796 KiB
01_handmade_09.txt AC 20 ms 9528 KiB
02_random_00.txt AC 57 ms 16672 KiB
02_random_01.txt AC 30 ms 6744 KiB
02_random_02.txt AC 15 ms 4968 KiB
02_random_03.txt AC 35 ms 7004 KiB
02_random_04.txt AC 23 ms 5424 KiB
02_random_05.txt AC 22 ms 5680 KiB
03_killer_00.txt AC 29 ms 15060 KiB
03_killer_01.txt AC 27 ms 15048 KiB
03_killer_02.txt AC 36 ms 22456 KiB