This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Gude - Seletiva IOI - OBI 2015 | |
#include <bits/stdc++.h> | |
#define endl '\n' | |
using namespace std; | |
typedef long long ll; | |
int main(){ | |
cin.tie(0); | |
ios_base::sync_with_stdio(0); | |
ll n,s,resposta=0LL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Estação - Seletiva IOI - OBI 2015 | |
#include <bits/stdc++.h> | |
#define MAXN 200010 | |
using namespace std; | |
vector<int> grafo[MAXN],pares1,pares2,impares1,impares2; | |
queue<int> fila1, fila2; | |
int grau1[MAXN],grau2[MAXN],nivel1[MAXN],nivel2[MAXN],maximo1=2 , maximo2=2, n,m; | |
int main(){ | |
scanf("%d %d",&n,&m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Intervalo - Seletiva IOI - OBI 2014 | |
#include <bits/stdc++.h> | |
#define MAXN 200010 | |
#define LSOne(S) (S&(-S)) | |
using namespace std; | |
typedef long long ll; | |
ll bit[MAXN]; | |
int freq[MAXN],acao[MAXN],vetor1[MAXN],vetor2[MAXN],n,q; | |
void atualiza_freq(int pos,int val){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Pedras - Seletiva IOI - OBI 2015 | |
#include <bits/stdc++.h> | |
#define MAXN 100010 | |
using namespace std; | |
typedef struct mo_que{ | |
int left,right,idx; | |
}que; | |
unordered_map<int,int> compressao; | |
int frequencia[MAXN],vetor[MAXN],resposta[MAXN],conjunto[MAXN],mo_left,mo_right,contador,n,sqn,q,maximo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Macacos me mordam! - Fase 2 Programação Nível 2 - OBI 2015 | |
// O(n*log(n)) | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
struct point{ | |
ll x,y; | |
}; | |
bool comp(point A, point B){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// O Banco Inteligente - Fase 1 Programação Nível 2 - OBI 2015 | |
// O(n*S) | |
// n = n_2 + n_5 + n_10 + n_20 + n_50 + n_100 | |
#include <bits/stdc++.h> | |
#define MAXS 5001 | |
typedef long long ll; | |
ll modos[MAXS], temp[MAXS], qtd[10],n,vetor[10] = {2,5,10,20,50,100}; | |
int main(){ | |
scanf("%lld",&n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Inversor - Seletiva IOI - OBI 2014 | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
const ll MAXN = 100010; | |
const ll NEG = -1*(1e13); | |
ll soma[MAXN],best[MAXN],resp; | |
int main(){ | |
ll N,K; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Pagamento - Seletiva IOI - OBI 2013 | |
#include <bits/stdc++.h> | |
using namespace std; | |
#define MAXN 4001 | |
typedef long long ll; | |
const ll INF = 1e15; | |
ll soma[MAXN][MAXN]; | |
ll C[MAXN]; | |
ll F[MAXN][MAXN]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Joining Couples - ACM/ICPC South America Contest 2012 | |
//UVA - 12533 | |
//URI - 1302 | |
//O(n*sqrt(h)) | |
#include <bits/stdc++.h> | |
#define MAXN 100010 | |
using namespace std; | |
vector<int> grafo[MAXN]; | |
int vaipara[MAXN],n,q,pai[MAXN],paisubarvore[MAXN],ancestral[MAXN],superancestral[MAXN],nivel[MAXN],tamanho[MAXN],valor[MAXN],segmento; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ivan Carvalho | |
// Arranging Heaps - ACM/ICPC South America Contest 2012 | |
//UVA - 12524 | |
//URI - 1282 | |
//O(n*k*log2(n)) | |
#include <bits/stdc++.h> | |
#define MAXN 1001 | |
using namespace std; | |
typedef long long ll; | |
const ll INF = 1e15; |