# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102122 | 2019-03-22T15:23:53 Z | jwvg0425 | 스파이 (JOI13_spy) | C++17 | 373 ms | 36608 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]; int counts[2005][2005]; int table[2005][2005]; int solve(int i, int j) { if (i == 0 || j == 0) return 0; if (table[i][j] != -1) return table[i][j]; int& ans = table[i][j]; ans = counts[i][j] + solve(iparent[i], j) + solve(i, jparent[j]) - solve(iparent[i], jparent[j]); return ans; } int main() { memset(table, -1, sizeof(table)); 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); } for (int i = 1; i <= m; i++) { int r, s; scanf("%d %d", &r, &s); counts[s][r]++; } for (int i = 1; i <= n; i++) printf("%d\n", solve(i, i)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 16640 KB | Output is correct |
2 | Correct | 18 ms | 16256 KB | Output is correct |
3 | Correct | 14 ms | 16512 KB | Output is correct |
4 | Correct | 15 ms | 16444 KB | Output is correct |
5 | Correct | 16 ms | 16640 KB | Output is correct |
6 | Correct | 27 ms | 16284 KB | Output is correct |
7 | Correct | 17 ms | 16640 KB | Output is correct |
8 | Correct | 18 ms | 16640 KB | Output is correct |
9 | Correct | 18 ms | 16128 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 128 ms | 22620 KB | Output is correct |
2 | Correct | 92 ms | 16632 KB | Output is correct |
3 | Correct | 22 ms | 19584 KB | Output is correct |
4 | Correct | 21 ms | 18688 KB | Output is correct |
5 | Correct | 33 ms | 22144 KB | Output is correct |
6 | Correct | 28 ms | 16504 KB | Output is correct |
7 | Correct | 131 ms | 22648 KB | Output is correct |
8 | Correct | 41 ms | 22520 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 282 ms | 32120 KB | Output is correct |
2 | Correct | 223 ms | 20984 KB | Output is correct |
3 | Correct | 161 ms | 32632 KB | Output is correct |
4 | Correct | 176 ms | 36608 KB | Output is correct |
5 | Correct | 242 ms | 36344 KB | Output is correct |
6 | Correct | 141 ms | 21180 KB | Output is correct |
7 | Correct | 373 ms | 36488 KB | Output is correct |
8 | Correct | 247 ms | 36472 KB | Output is correct |