# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
398573 | jlallas384 | The Xana coup (BOI21_xanadu) | C++17 | 124 ms | 25148 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100100;
ll dp[N][2][2],col[N];
vector<int> g[N];
ll f(int v,int p,int c,int flp){
if(dp[v][c][flp] != -1) return dp[v][c][flp];
vector<pair<ll,ll>> a;
for(int u: g[v]) if(u != p){
a.emplace_back(f(u,v,col[u]^flp,0),f(u,v,col[u]^flp^1,1)+1);
}
vector<ll> ndp(2,1e9);
ndp[0] = 0;
for(int i = 0; i < a.size(); i++){
vector<ll> mdp(2,1e9);
mdp[0] = min(ndp[0] + a[i].first,ndp[1] + a[i].second);
mdp[1] = min(ndp[1] + a[i].first,ndp[0] + a[i].second);
ndp = mdp;
}
return dp[v][c][flp] = ndp[c^1];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |