# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
24891 | 2017-06-17T04:26:10 Z | dotorya | 스파이 (JOI13_spy) | C++14 | 239 ms | 18704 KB |
#include <stdio.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #pragma warning(disable:4996) #pragma comment(linker, "/STACK:336777216") using namespace std; #define mp make_pair #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) ((int)(x).size()) #define rep(i, n) for(int i=0;i<n;i++) #define all(x) (x).begin(), (x).end() #define ldb ldouble typedef tuple<int, int, int> t3; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef pair <db, db> pdd; int IT_MAX = 1 << 13; const ll MOD = 1000000007; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const db PI = acos(-1); const db ERR = 1E-11; vector <int> son[2][2050]; bool dchk[2][2050]; int lr[2][2050][2]; int tus[2]; void DFS(int x, int n) { dchk[x][n] = true; lr[x][n][0] = ++tus[x]; for (auto it : son[x][n]) { if (dchk[x][it]) continue; DFS(x, it); } lr[x][n][1] = tus[x]; } int del[2050][2050]; int main() { int N, M, i, j, t1, t2; scanf("%d %d", &N, &M); int R[2] = { 0,0 }; for (i = 1; i <= N; i++) { for (j = 0; j < 2; j++) { scanf("%d", &t1); if (t1 == 0) R[j] = i; else son[j][t1].push_back(i); } } for (i = 0; i < 2; i++) DFS(i, R[i]); while (M--) { int t1, t2; scanf("%d %d", &t1, &t2); del[lr[0][t1][0]][lr[1][t2][0]]++; del[lr[0][t1][0]][lr[1][t2][1] + 1]--; del[lr[0][t1][1] + 1][lr[1][t2][0]]--; del[lr[0][t1][1] + 1][lr[1][t2][1] + 1]++; } for (i = 1; i <= N; i++) for (j = 1; j <= N; j++) del[i][j] += del[i - 1][j] + del[i][j - 1] - del[i - 1][j - 1]; for (i = 1; i <= N; i++) printf("%d\n", del[lr[0][i][0]][lr[1][i][0]]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18568 KB | Output is correct |
2 | Correct | 0 ms | 18568 KB | Output is correct |
3 | Correct | 0 ms | 18568 KB | Output is correct |
4 | Correct | 0 ms | 18568 KB | Output is correct |
5 | Correct | 0 ms | 18568 KB | Output is correct |
6 | Correct | 0 ms | 18568 KB | Output is correct |
7 | Correct | 0 ms | 18568 KB | Output is correct |
8 | Correct | 0 ms | 18568 KB | Output is correct |
9 | Correct | 0 ms | 18568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 18704 KB | Output is correct |
2 | Correct | 19 ms | 18704 KB | Output is correct |
3 | Correct | 6 ms | 18568 KB | Output is correct |
4 | Correct | 19 ms | 18568 KB | Output is correct |
5 | Correct | 16 ms | 18700 KB | Output is correct |
6 | Correct | 6 ms | 18700 KB | Output is correct |
7 | Correct | 16 ms | 18700 KB | Output is correct |
8 | Correct | 23 ms | 18700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 196 ms | 18700 KB | Output is correct |
2 | Correct | 129 ms | 18704 KB | Output is correct |
3 | Correct | 146 ms | 18568 KB | Output is correct |
4 | Correct | 156 ms | 18568 KB | Output is correct |
5 | Correct | 216 ms | 18700 KB | Output is correct |
6 | Correct | 116 ms | 18700 KB | Output is correct |
7 | Correct | 179 ms | 18700 KB | Output is correct |
8 | Correct | 239 ms | 18700 KB | Output is correct |