Skip to content

Instantly share code, notes, and snippets.

@IvanIsCoding
Created August 25, 2018 00:40
Show Gist options
  • Save IvanIsCoding/7d5609cd161b9abed9a65185fc30dc89 to your computer and use it in GitHub Desktop.
Save IvanIsCoding/7d5609cd161b9abed9a65185fc30dc89 to your computer and use it in GitHub Desktop.
Japanese Olympiad in Informatics Spring Camp 2015
// Ivan Carvalho
// Navigation - JOI SC 2015
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
static vector<int> grafo[MAXN];
static int cor[MAXN];
void dfs(int v,int p){
for(int u : grafo[v]){
if(u == p) continue;
int davez = (v < u) + cor[v];
if(davez % 2 == 0){
cor[u] = 0;
}
else{
cor[u] = 1;
}
dfs(u,v);
}
}
void Anna(int K, int N, int T, int A[], int B[]) {
for(int i = 0;i<N-1;i++){
grafo[A[i]].push_back(B[i]);
grafo[B[i]].push_back(A[i]);
}
dfs(T,-1);
for(int i = 1;i<=N;i++) Flag(i,cor[i]);
}
// Ivan Carvalho
// Navigation - JOI SC 2015
#include "Brunolib.h"
void Bruno(int K, int S, int F, int L, int P[], int Q[]){
int hasAns = 0;
for(int i = 0;i<L;i++){
int outro = P[i];
int davez = (S < outro) + (F) + (Q[i]);
if(davez % 2 == 1){
hasAns = 1;
Answer(outro);
}
}
if(!hasAns) Answer(S);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment