# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
478869 |
2021-10-08T16:24:47 Z |
Neos |
스파이 (JOI13_spy) |
C++14 |
|
216 ms |
24700 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
#define task "test"
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- )
#define sz(x) (int)x.size()
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define numBit(x) __builtin_popcount(x)
#define lb lower_bound
#define ub upper_bound
#define ar array
#define endl '\n'
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const int N = 2e3 + 7;
const ll inf = 0x3f3f3f3f;
int n, m, root[N], dp[N][N], par[2][N];
bool avail[N][N];
int DP(int i, int j) {
if (avail[i][j]) return dp[i][j];
avail[i][j] = 1;
if (i != root[0]) dp[i][j] += DP(par[0][i], j);
if (j != root[1]) dp[i][j] += DP(i, par[1][j]);
if (i != root[0] && j != root[1]) dp[i][j] -= DP(par[0][i], par[1][j]);
return dp[i][j];
}
int main() {
// fastIO;
scanf("%d %d", &n, &m);
forw(i, 0, n) forw(j, 0, 2) {
int a; scanf("%d", &a);
if (!a) root[j] = i; else par[j][i] = --a;
}
forw(i, 0, m) {
int r, s; scanf("%d %d", &r, &s);
++dp[--r][--s];
}
forw(i, 0, n) printf("%d\n", DP(i, i));
}
Compilation message
spy.cpp: In function 'int main()':
spy.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
spy.cpp:54:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | int a; scanf("%d", &a);
| ~~~~~^~~~~~~~~~
spy.cpp:59:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | int r, s; scanf("%d %d", &r, &s);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1616 KB |
Output is correct |
2 |
Correct |
2 ms |
1616 KB |
Output is correct |
3 |
Correct |
1 ms |
1584 KB |
Output is correct |
4 |
Correct |
1 ms |
1488 KB |
Output is correct |
5 |
Correct |
1 ms |
1616 KB |
Output is correct |
6 |
Correct |
1 ms |
1620 KB |
Output is correct |
7 |
Correct |
2 ms |
1616 KB |
Output is correct |
8 |
Correct |
1 ms |
1616 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
20080 KB |
Output is correct |
2 |
Correct |
103 ms |
20148 KB |
Output is correct |
3 |
Correct |
11 ms |
16136 KB |
Output is correct |
4 |
Correct |
10 ms |
16336 KB |
Output is correct |
5 |
Correct |
18 ms |
19964 KB |
Output is correct |
6 |
Correct |
23 ms |
19984 KB |
Output is correct |
7 |
Correct |
110 ms |
20016 KB |
Output is correct |
8 |
Correct |
20 ms |
19920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
191 ms |
24580 KB |
Output is correct |
2 |
Correct |
160 ms |
24348 KB |
Output is correct |
3 |
Correct |
109 ms |
20552 KB |
Output is correct |
4 |
Correct |
132 ms |
24700 KB |
Output is correct |
5 |
Correct |
183 ms |
24312 KB |
Output is correct |
6 |
Correct |
95 ms |
23776 KB |
Output is correct |
7 |
Correct |
216 ms |
24260 KB |
Output is correct |
8 |
Correct |
160 ms |
24320 KB |
Output is correct |