Submission #906053

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9060532024-01-13 12:21:00MathiasThe Xana coup (BOI21_xanadu)C++14
100 / 100
66 ms20564 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 1e5+7;
const long long INF = 1e9+7;
long long dp[MAXN][3][3];
bool t[MAXN], visited[MAXN];
vector<long long> g[MAXN];
long long n,a,b,c,d;
void DFS(int x,int f){
visited[x]=1;
if(t[x]){
dp[x][1][0]=1;
dp[x][0][1]=0;
}
else{
dp[x][1][1]=1;
dp[x][0][0]=0;
}
for(int i=0;i<g[x].size();i++){
if(visited[g[x][i]]==1) continue;
int s=g[x][i];
DFS(s,x);
}
for(int i=0;i<g[x].size();i++){
int s=g[x][i];
if(s==f) continue;
a=dp[x][0][0], b=dp[x][0][1], c=dp[x][1][0], d=dp[x][1][1];
dp[x][0][0]=min(a+dp[s][0][0], b+dp[s][1][0]);
dp[x][0][1]=min(b+dp[s][0][0], a+dp[s][1][0]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

xanadu.cpp: In function 'void DFS(int, int)':
xanadu.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<g[x].size();i++){
      |              ~^~~~~~~~~~~~
xanadu.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0;i<g[x].size();i++){
      |              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...