Submission #418022

#TimeUsernameProblemLanguageResultExecution timeMemory
418022JerryLiu06Uzastopni (COCI15_uzastopni)C++17
160 / 160
24 ms4340 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<db>; using vs = vector<str>; using vpi = vector<pi>; using vpl = vector<pl>; using vpd = vector<pd>; #define mp make_pair #define f first #define s second #define sz(x) (int)(x).size() #define bg(x) begin(x) #define all(x) bg(x), end(x) #define sor(x) sort(all(x)) #define ft front() #define bk back() #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define EACH(a,x) for (auto& a: x) const int MOD = 1e9 + 7; const int MXN = 1e5 + 10; const int MXV = 101; const ll INF = 1e18; int N, V[MXN]; vi child[MXN]; bitset<MXV> low[MXN], high[MXN]; // # of possible lowests, highests bitset<MXV> LOW[MXV], HIGH[MXV]; // LOW[C1][C2] means C2 must be the lowest, with C1 as the highest void solve(int X) { low[X][V[X]] = high[X][V[X]] = 1; EACH(C, child[X]) solve(C); FOR(i, 1, MXV) LOW[i].reset(), HIGH[i].reset(); EACH(C, child[X]) FOR(i, 1, MXV) if (low[C][i]) FOR(j, 1, MXV) if (high[C][j]) { if (j < V[X]) LOW[j][i] = 1; if (i > V[X]) HIGH[i][j] = 1; } ROF(i, 2, V[X] + 1) if (low[X][i]) low[X] |= LOW[i - 1]; FOR(i, V[X], MXV - 1) if (high[X][i]) high[X] |= HIGH[i + 1]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N; FOR(i, 1, N + 1) cin >> V[i]; F0R(i, N - 1) { int A, B; cin >> A >> B; child[A].pb(B); } solve(1); cout << low[1].count() * high[1].count(); }

Compilation message (stderr)

uzastopni.cpp: In function 'void solve(int)':
uzastopni.cpp:60:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   60 |         if (j < V[X]) LOW[j][i] = 1; if (i > V[X]) HIGH[i][j] = 1;
      |         ^~
uzastopni.cpp:60:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   60 |         if (j < V[X]) LOW[j][i] = 1; if (i > V[X]) HIGH[i][j] = 1;
      |                                      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...