結果
問題 | No.2052 Indegree |
ユーザー | fact493 |
提出日時 | 2022-08-21 12:51:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 7,736 bytes |
コンパイル時間 | 4,740 ms |
コンパイル使用メモリ | 250,168 KB |
実行使用メモリ | 15,376 KB |
最終ジャッジ日時 | 2024-10-10 05:52:36 |
合計ジャッジ時間 | 5,535 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
15,356 KB |
testcase_01 | AC | 18 ms
15,360 KB |
testcase_02 | AC | 18 ms
15,160 KB |
testcase_03 | AC | 18 ms
15,276 KB |
testcase_04 | AC | 17 ms
15,176 KB |
testcase_05 | AC | 17 ms
15,360 KB |
testcase_06 | AC | 17 ms
15,360 KB |
testcase_07 | AC | 18 ms
15,232 KB |
testcase_08 | AC | 18 ms
15,360 KB |
testcase_09 | AC | 18 ms
15,232 KB |
testcase_10 | AC | 18 ms
15,376 KB |
testcase_11 | AC | 17 ms
15,232 KB |
testcase_12 | AC | 18 ms
15,232 KB |
testcase_13 | AC | 18 ms
15,232 KB |
testcase_14 | AC | 18 ms
15,360 KB |
testcase_15 | AC | 18 ms
15,360 KB |
testcase_16 | AC | 19 ms
15,232 KB |
testcase_17 | AC | 18 ms
15,360 KB |
testcase_18 | AC | 17 ms
15,320 KB |
testcase_19 | AC | 18 ms
15,228 KB |
testcase_20 | AC | 19 ms
15,292 KB |
testcase_21 | AC | 19 ms
15,324 KB |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll = long long;using vl = vector<ll>;using vvl = vector<vl>;using vvvl = vector<vvl>;typedef pair<ll, ll> P;typedef tuple<ll, ll, ll> PP;typedef tuple<ll, ll, ll, ll> PPP;using vvvvl = vector<vvvl>;using vp = vector<P>;using vvp = vector<vp>;using vb = vector<bool>;using vvb = vector<vb>;#define lb(v, k) (lower_bound(all(v), (k)) - v.begin())#define ub(v, k) (upper_bound(all(v), (k)) - v.begin())#define eb emplace_back#define fi first#define se second#define pq(T) priority_queue<T>#define pqr(T) priority_queue<T, vector<T>, greater<T>>#define pcount(i) __builtin_popcount(i);#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)#define all(a) (a).begin(), (a).end()#define double long double#define yesno(i) if(i)cout<<"yes"<<endl;else cout<<"no"<<endl;#define YesNo(i) if(i)cout<<"Yes"<<endl;else cout<<"No"<<endl;#define YESNO(i) if(i)cout<<"YES"<<endl;else cout<<"NO"<<endl;#define cinvec(x) \for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \{ \cin >> x.at(hfuaig); \}#define coutvece(x) \for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \{ \cout << x.at(hfuaig) << endl; \}#define coutvec(x) \for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \{ \cout << x.at(hfuaig) << ' '; \}template <typename T>bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}template <typename T>bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}const ll mod = 998244353;const ll Mod = 1000000007;const ll inf = 999999999999999999LL;#pragma GCC target("avx")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")ll gcd(ll A, ll B){if(A % B == 0){return B;}else{return gcd(B, A % B);}}ll lcm(ll A, ll B){return A * B / gcd(A, B);}long long modpow(long long a, long long n, long long mo) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mo;a = a * a % mo;n >>= 1;}return res;}//円の位置関係bool isd(double a, double b, double c){if(c > (a + b) * (a + b)){return false;}if(c == (a + b) * (a + b)){return true;}if(abs(a - b) * abs(a - b) < c && c < (a + b) * (a + b)){return true;}if(c == abs(a - b) * abs(a - b)){return true;}if(c < abs(a - b) * abs(a - b)){return false;}return true;}const int MAX = 500000;const int MOD = mod;ll fact[MAX], inv_fact[MAX], inv[MAX];void init() {// 初期値設定と1はじまりインデックスに直すfact[0] = 1;fact[1] = 1;inv[0] = 1;inv[1] = 1;inv_fact[0] = 1;inv_fact[1] = 1;// メモの計算repi(i, 2, MAX){// 階乗fact[i] = fact[i - 1] * i % MOD;// 逆元inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;// 逆元の階乗inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;}}ll nck(int n, int k) {ll x = fact[n]; // n!の計算ll y = inv_fact[n-k]; // (n-k)!の計算ll z = inv_fact[k]; // k!の計算if (n < k) return 0; // 例外処理if (n < 0 || k < 0) return 0; // 例外処理return x * ((y * z) % MOD) % MOD; //二項係数の計算}struct Edge {long long to;long long cost;};struct graph{vvp G;vl dis;vl prev;vl dijkstra(ll i){ll N = G.size();dis.assign(N, inf);prev.assign(N, -1);priority_queue<P, vector<P>, greater<P>> pq; // 「仮の最短距離, 頂点」が小さい順に並ぶdis[i] = 0;pq.emplace(dis[i], i);while (!pq.empty()) {P p = pq.top();pq.pop();ll v = p.second;if (dis[v] < p.first) { // 最短距離で無ければ無視continue;}for (auto &e : G[v]) {if (dis[e.fi] > dis[v] + e.se) { // 最短距離候補なら priority_queue に追加dis[e.fi] = dis[v] + e.se;prev[e.fi] = v;pq.emplace(dis[e.fi], e.fi);}}}return dis;}vl get_path(ll t){vl path;for (ll cur = t; cur != -1; cur = prev[cur]) {path.push_back(cur);}reverse(path.begin(), path.end()); // 逆順なのでひっくり返すreturn path;}};void beg(){ios::sync_with_stdio(false);std::cin.tie(nullptr);cout << fixed << setprecision(20);init();srand((unsigned int)time(NULL));}struct BIT {private:vector<int> bit;ll N;public:BIT(ll size) {N = size;bit.resize(N + 1, 0);}// 一点更新ですvoid add(ll a, ll w) {for (int x = a; x <= N; x += x & -x) bit[x] += w;}// 1~Nまでの和を求める。ll sum(ll a) {ll ret = 0;for (ll x = a; x > 0; x -= x & -x) ret += bit[x];return ret;}};//転倒数ライブラリll numfalls(vl &A){ll ans = 0;ll N = A.size();BIT b(N);rep(i, N){ans += i - b.sum(A.at(i));b.add(A.at(i), 1);}return ans;}//#define _GLIBCXX_DEBUG#define mint998 modint998244353#define mint107 modint1000000007//約数列挙vector<long long> div(long long n) {vector<long long> ret;set<ll> re;ll N = sqrt(n) + 1;for (long long i = 1; i <= N; i++) {if (n % i == 0) {re.insert(n / i);re.insert(i);}}for(auto value :re){ret.push_back(value);}return ret;}ll digit_sum(ll X){ll ans = 0;while(X > 0){ans += X%10;X/=10;}return ans;}void xypress(vl &A){vl B = A;sort(all(B));B.erase(unique(B.begin(), B.end()), B.end());vector<ll> res(A.size());for (int i = 0; i < A.size(); ++i) {res[i] = lower_bound(B.begin(), B.end(), A[i]) - B.begin();}A = res;}//素数列挙std::vector<ll> prime( const ll N ){std::vector<bool> is_prime( N + 1 );for( ll i = 0; i <= N; i++ ){is_prime[ i ] = true;}std::vector<ll> P;for( ll i = 2; i <= N; i++ ){if( is_prime[ i ] ){for( ll j = 2 * i; j <= N; j += i ){is_prime[ j ] = false;}P.emplace_back( i );}}return P;}//mod m での逆元long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}//mod 998244353での割り算ll inve(ll a, ll b){a %= mod;return (a * modinv(b, mod) % mod);}vl vecsum(vl x){vl s = {0};rep(i, x.size()){s.push_back(s.back() + x.at(i));}return s;}signed main(){beg();ll N, M;cin >> N >> M;vl X(N);rep(i, M){ll a, b;cin >> a >> b;X.at(b - 1)++;}ll ans = 0;rep(i, N){if(X.at(i) == 0){ans++;}}cout << ans << endl;}