# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
102117 | 2019-03-22T14:38:03 Z | jwvg0425 | 스파이 (JOI13_spy) | C++17 | 2000 ms | 219908 KB |
#include <stdio.h> #include <vector> #include <queue> #include <algorithm> #include <iostream> #include <string> #include <bitset> #include <map> #include <set> #include <tuple> #include <string.h> #include <math.h> #include <random> #include <functional> #include <assert.h> #include <math.h> #include <iterator> #include <chrono> #define all(x) (x).begin(), (x).end() #define xx first #define yy second using namespace std; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; using vi = vector<long long int>; int iparent[2005]; int jparent[2005]; vector<int> ichild[2005]; vector<int> jchild[2005]; vector<int> iteams[2005]; vector<int> jteams[2005]; int iroot; int jroot; void idfs(int root, int team) { iteams[root].push_back(team); for (auto& c : ichild[root]) idfs(c, team); } void jdfs(int root, int team) { jteams[root].push_back(team); for (auto& c : jchild[root]) jdfs(c, team); } int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { int p, q; scanf("%d %d", &p, &q); jparent[i] = p; jchild[p].push_back(i); iparent[i] = q; ichild[q].push_back(i); if (jparent[i] == 0) jroot = i; if (iparent[i] == 0) iroot = i; } for (int i = 1; i <= m; i++) { int r, s; scanf("%d %d", &r, &s); jdfs(r, i); idfs(s, i); } for (int i = 1; i <= n; i++) { sort(all(jteams[i])); int c = 0; for (auto& it : iteams[i]) { if (binary_search(all(jteams[i]), it)) c++; } printf("%d\n", c); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 768 KB | Output is correct |
2 | Correct | 6 ms | 896 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 7 ms | 1068 KB | Output is correct |
5 | Correct | 2 ms | 640 KB | Output is correct |
6 | Correct | 7 ms | 896 KB | Output is correct |
7 | Correct | 3 ms | 640 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 3 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 361 ms | 22812 KB | Output is correct |
2 | Correct | 713 ms | 33104 KB | Output is correct |
3 | Correct | 261 ms | 16840 KB | Output is correct |
4 | Correct | 411 ms | 32868 KB | Output is correct |
5 | Correct | 23 ms | 1792 KB | Output is correct |
6 | Correct | 534 ms | 33144 KB | Output is correct |
7 | Correct | 71 ms | 5112 KB | Output is correct |
8 | Correct | 11 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2069 ms | 219908 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |