# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
876599 | davinpwk | The Xana coup (BOI21_xanadu) | C++14 | 42 ms | 15720 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;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define TC int t; cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
//*AC BERSAMA ALLAH FORTIS FORTUNA ADIUVAT
const ll nx = 1e5+5;
vector<ll> adj[nx];
bool on[nx], vis[nx];
ll dp[nx][2][2];
ll n;
void dfs(ll nd){
vis[nd] = 1;
if(on[nd])
dp[nd][1][0] = 1, dp[nd][0][1] = 0;
else
dp[nd][1][1] = 1, dp[nd][0][0] = 0;
for(ll i : adj[nd]){
if(!vis[i]){
dfs(i);
ll x = dp[nd][0][0], y = dp[nd][0][1];
dp[nd][0][0] = min(x + dp[i][0][0], y + dp[i][1][0]);
dp[nd][0][1] = min(y + dp[i][0][0], x + dp[i][1][0]);
x = dp[nd][1][0], y = dp[nd][1][1];
dp[nd][1][0] = min(x + dp[i][0][1], y + dp[i][1][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... |