Submission #1057023

#TimeUsernameProblemLanguageResultExecution timeMemory
1057023panUzastopni (COCI15_uzastopni)C++17
88 / 160
72 ms43196 KiB
#include <bits/stdc++.h> //#include "bits_stdc++.h" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define f first #define s second #define pb push_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define input(x) scanf("%lld", &x); #define input2(x, y) scanf("%lld%lld", &x, &y); #define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z); #define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a); #define print(x, y) printf("%lld%c", x, y); #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; #define all(x) x.begin(), x.end() #define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); #define FOR(i, x, n) for (ll i =x; i<=n; ++i) #define RFOR(i, x, n) for (ll i =x; i>=n; --i) using namespace std; //using namespace __gnu_pbds; //#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> //#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> typedef long long ll; typedef long double ld; typedef pair<ld, ll> pd; typedef pair<string, ll> psl; typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; typedef pair<pi, pi> piii; ll const MAXN = 10000, MAXV = 100; ll n, v, e; vector<ll> adj[10005]; bitset<105> dp[10005][105]; vector<pi> s[10005]; vector<ll> nxt[105]; ll val[10005]; void dfs(ll x) { for (ll i=1; i<=MAXV; ++i) nxt[i].clear(); for (ll u: adj[x]) dfs(u); for (ll u: adj[x]) for (pi a: s[u]) nxt[a.f].pb(a.s); for (ll i = MAXV; i>=1; --i) { if (i == val[x]) // {val[x]} U other pairs { dp[x][i] |= dp[x][i+1]; dp[x][i][i] = 1; continue; } // pair U other pairs for (ll u: nxt[i]) { //show(u); if (u < val[x] || i > val[x]) { dp[x][i] |= dp[x][u+1]; dp[x][i][u] = 1; //cout << dp[x][i] << endl; } } } for (ll i = 1; i<=val[x] ; ++i) for (ll j=val[x]; j<=MAXV; ++j) if (dp[x][i][j]) s[x].pb(mp(i, j)); //show(x); //for (pi u: s[x]) show2(u.f, u.s); } int main() { input(n); for (ll i=1; i<=n; ++i) input(val[i]); for (ll i=0; i<n-1; ++i) { input2(v, e); adj[v].pb(e); } dfs(1); ll ans = s[1].size(); print(ans, '\n'); return 0; }

Compilation message (stderr)

uzastopni.cpp: In function 'int main()':
uzastopni.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
uzastopni.cpp:76:2: note: in expansion of macro 'input'
   76 |  input(n);
      |  ^~~~~
uzastopni.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
uzastopni.cpp:77:26: note: in expansion of macro 'input'
   77 |  for (ll i=1; i<=n; ++i) input(val[i]);
      |                          ^~~~~
uzastopni.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define input2(x, y) scanf("%lld%lld", &x, &y);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~
uzastopni.cpp:80:3: note: in expansion of macro 'input2'
   80 |   input2(v, e);
      |   ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...