Submission #826154
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const ll INF = 1000000000ll; const ll MOD = 1000000007ll; const double EPS = 1e-8; int main(void) { //ios_base::sync_with_stdio(false); //cin.tie(0); int n, m; cin >> n >> m; vector<int> box(n, 1); box[0] = 0; vector<int> rbox(n, 0); rbox[0] = 1; vector<int> x; vector<int> y; vector<int> nx(n, 0); vector<int> ny(n, 0); vector<bool> flag(n, false); for(int i=0; i<m; i++){ int t1, t2; cin >> t1 >> t2; t1--; t2--; x.push_back(t1); y.push_back(t2); nx[t1]++; ny[t2]++; } if(ny[0] + box[0] - nx[0] >= 0){ flag[0] == true; } for(int i=0; i<m; i++){ int tx = x[i]; int ty = y[i]; nx[tx]--; ny[ty]--; if(rbox[tx] == 1){ if(ny[ty] + box[ty] - nx[ty] >= 0){ //printf("%d %d %d\n", i, tx, ty); flag[ty] = true; } rbox[tx] = 0; rbox[ty] = 1; }else{ box[tx]--; box[ty]++; } } int ans = 0; for(int i=0; i<n; i++){ //cout << flag[i] << endl; if(flag[i]) ans++; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Box and Ball |
User | tanutarou |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1142 Byte |
Status | WA |
Exec Time | 110 ms |
Memory | 2812 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 4 ms | 256 KB |
0_01.txt | AC | 4 ms | 256 KB |
0_02.txt | AC | 4 ms | 256 KB |
1_00.txt | AC | 4 ms | 256 KB |
1_01.txt | WA | 4 ms | 256 KB |
1_02.txt | AC | 4 ms | 256 KB |
1_03.txt | WA | 4 ms | 256 KB |
1_04.txt | WA | 91 ms | 2812 KB |
1_05.txt | AC | 110 ms | 2812 KB |
1_06.txt | WA | 86 ms | 2044 KB |
1_07.txt | AC | 106 ms | 2044 KB |
1_08.txt | WA | 72 ms | 1532 KB |
1_09.txt | WA | 71 ms | 2300 KB |
1_10.txt | WA | 26 ms | 1664 KB |
1_11.txt | WA | 41 ms | 1024 KB |
1_12.txt | WA | 10 ms | 1792 KB |
1_13.txt | WA | 89 ms | 2172 KB |
1_14.txt | WA | 48 ms | 1148 KB |
1_15.txt | WA | 79 ms | 1404 KB |
1_16.txt | WA | 7 ms | 1152 KB |
1_17.txt | WA | 106 ms | 2812 KB |
1_18.txt | WA | 94 ms | 1916 KB |
1_19.txt | WA | 101 ms | 1660 KB |
1_20.txt | WA | 94 ms | 1532 KB |
1_21.txt | WA | 82 ms | 1916 KB |
1_22.txt | WA | 106 ms | 2172 KB |
1_23.txt | WA | 32 ms | 1664 KB |