Submission #478869

#TimeUsernameProblemLanguageResultExecution timeMemory
478869Neos스파이 (JOI13_spy)C++14
100 / 100
216 ms24700 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...