# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
478869 | | Neos | 스파이 (JOI13_spy) | C++14 | | 216 ms | 24700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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);
| ~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |