# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796361 | Dan4Life | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 2066 ms | 162276 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;
#define pb push_back
#define int long long
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2e5+10;
const int LINF = (int)2e18;
int n;
unordered_map<int,int> dp[mxN];
int a[mxN], h[mxN], c[mxN];
vector<int> adj[mxN];
set<int> S[mxN];
int recur(int s, int v){
if(dp[s].count(v)) return dp[s][v];
int ans = (v!=h[s])*c[s];
S[s].insert(h[s]);
for(auto u : adj[s]){
ans+=recur(u,v);
if(sz(S[s])<sz(S[u])) S[s].swap(S[u]);
for(auto u : S[u]) S[s].insert(u);
}
for(auto u : S[s]) if(u>v) ans = min(ans, recur(s,u));
return dp[s][v]=ans;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |