# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026048 | warrenn | The Xana coup (BOI21_xanadu) | C++17 | 69 ms | 16724 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 int long long
const int maxn=1e5+5;
int n;
vector<int>adj[maxn];
int dp[maxn][2][2]; // idx,nyala,toggle
bool vis[maxn];
bool on[maxn];
void dfs(int cur){
vis[cur]=true;
if(on[cur]){
dp[cur][1][0]=0;
dp[cur][0][1]=1;
}
else{
dp[cur][0][0]=0;
dp[cur][1][1]=1;
}
for(auto r : adj[cur]){
if(vis[r])continue;
dfs(r);
// jangan toggle
int q=dp[cur][0][0]; int w=dp[cur][1][0];
dp[cur][0][0]=min(q+dp[r][0][0],w+dp[r][0][1]);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |