結果

問題 No.2052 Indegree
ユーザー kpinkcat
提出日時 2023-09-22 17:13:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 1,809 ms
コンパイル使用メモリ 194,244 KB
最終ジャッジ日時 2025-02-17 00:06:18
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:26: warning: ‘cnt’ may be used uninitialized [-Wmaybe-uninitialized]
   25 |         if(g[i] == 0) cnt++;
      |                       ~~~^~
main.cpp:16:14: note: ‘cnt’ was declared here
   16 |     ll n, m, cnt;
      |              ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;

int main()
{
    ll n, m, cnt;
    cin >> n >> m;
    vector<ll> g(n+1);
    for (int i = 0; i < m; i++){
        int out, in;
        cin >> out >> in;
        g[in]++;
    }
    for (int i = 1; i < n + 1; i++){
        if(g[i] == 0) cnt++;
    }
    cout << cnt << endl;
}
0