Submission #8529508
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b) for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n) For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x) cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//ここから書き始める
ll combination(ll n, ll i){
ll count = 0;
ll multi = 1;
ll div =1;
int limit = i;
while(count < limit){
multi *= n;
n--;
multi/= count+1;
count ++ ;
}
return multi / div;
}
int main()
{
cout <<setprecision(10);
ll n , m;
cin >> n >> m;
vector<ll> x(m),y(m);
rep(i,m){
cin >> x[i] >> y[i];
}
vector<pair<ll,bool>> boal(n); //個数 赤がありうるかそうかどうか
rep(i,n){
boal[i].first = 1;
boal[i].second = false;
}
boal[0].second = true;
ll ans = 0;
rep(i,m){
ll from = x[i]-1;
ll to = y[i]-1;
boal[from].first -- ;
boal[to].first ++;
if(boal[from].second){
if(boal[from].first == 0){
boal[from].second = false;
}
boal[to].second = true ;
}
}
rep(i,n){
if(boal[i].second){
ans ++ ;
}
}
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
B - Box and Ball |
User |
nibosea |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2212 Byte |
Status |
AC |
Exec Time |
57 ms |
Memory |
3328 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
AC |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
AC |
1 ms |
256 KB |
1_02.txt |
AC |
1 ms |
256 KB |
1_03.txt |
AC |
1 ms |
256 KB |
1_04.txt |
AC |
45 ms |
3328 KB |
1_05.txt |
AC |
57 ms |
3328 KB |
1_06.txt |
AC |
44 ms |
2560 KB |
1_07.txt |
AC |
56 ms |
2560 KB |
1_08.txt |
AC |
35 ms |
1792 KB |
1_09.txt |
AC |
37 ms |
2560 KB |
1_10.txt |
AC |
12 ms |
1664 KB |
1_11.txt |
AC |
21 ms |
1024 KB |
1_12.txt |
AC |
3 ms |
1664 KB |
1_13.txt |
AC |
47 ms |
2560 KB |
1_14.txt |
AC |
25 ms |
1280 KB |
1_15.txt |
AC |
42 ms |
1664 KB |
1_16.txt |
AC |
2 ms |
1152 KB |
1_17.txt |
AC |
55 ms |
3328 KB |
1_18.txt |
AC |
50 ms |
2304 KB |
1_19.txt |
AC |
53 ms |
2176 KB |
1_20.txt |
AC |
49 ms |
2048 KB |
1_21.txt |
AC |
43 ms |
2048 KB |
1_22.txt |
AC |
56 ms |
2688 KB |
1_23.txt |
AC |
15 ms |
1792 KB |