Skip to content

Instantly share code, notes, and snippets.

@IvanIsCoding
IvanIsCoding / falta.cpp
Last active July 11, 2017 15:28
Solução OBI 2016
// Ivan Carvalho
// Falta uma - Fase 2 Programação Nível 2 - OBI 2016
// O(n!)
#include <bits/stdc++.h>
int matriz[10][10];
int main(){
int n,total,subtotal=1;
scanf("%d",&n);
// calculamos (n-1)!
for(int i=1;i<n;i++) subtotal *= i;
@IvanIsCoding
IvanIsCoding / caminhos.cpp
Last active July 11, 2017 15:28
Seletiva IOI 2013
// Ivan Carvalho
// Caminhos - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
#define MAXN 5100
#define PESO first
#define U second.first
#define V second.second
#define endl '\n'
using namespace std;
@IvanIsCoding
IvanIsCoding / etiqueta.cpp
Last active July 11, 2017 15:28
Seletiva IOI 2013
// Ivan Carvalho
// Etiqueta - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
#define MAXN 200101
#define MP make_pair
ll arvore[4*MAXN],lazy[4*MAXN];
@IvanIsCoding
IvanIsCoding / codigo.cpp
Last active July 11, 2017 15:28
Seletiva IOI 2013
// Ivan Carvalho
// Código - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 100010
#define LSOne(S) (S & (-S))
int bit[MAXN];
void update(int ind){
while(ind < MAXN){
bit[ind]++;
ind += LSOne(ind);
@IvanIsCoding
IvanIsCoding / codreverso.cpp
Last active July 11, 2017 15:28
Seletiva IOI 2013
// Ivan Carvalho
// Código Reverso - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 500001
#define LSOne(S) (S&(-S))
int n,bit[MAXN],vetor[MAXN],exibir[MAXN];
void update(int pos, int val){
while(pos <= n){
bit[pos] += val;
pos += LSOne(pos);
@IvanIsCoding
IvanIsCoding / ilhas.cpp
Last active July 11, 2017 15:27
Seletiva IOI 2013
// Ivan Carvalho
// Ilhas - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 1010
int U[MAXN*MAXN],V[MAXN*MAXN],reservado[MAXN],pai[MAXN],peso[MAXN],pares[MAXN];
int find(int x){
if (x==pai[x]) return x;
return pai[x] = find(pai[x]);
}
void join(int x, int y){
@IvanIsCoding
IvanIsCoding / secreto.cpp
Last active July 11, 2017 15:27
Seletiva IOI 2013
// Ivan Carvalho
// Secreto - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 100010
#define endl '\n'
using namespace std;
int visitado1[MAXN],visitado2[MAXN],grafo[MAXN],transposto[MAXN];
stack<int> pilha;
void dfs1(int x){
//cout << "Kosaraju" << endl;
@IvanIsCoding
IvanIsCoding / superfat.cpp
Last active July 11, 2017 15:27
Seletiva IOI 2013
// Ivan Carvalho
// Superfaturamento - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define PESO first
#define U second.first
#define V second.second
#define PB push_back
#define MP make_pair
#define MAX 1001
using namespace std;
@IvanIsCoding
IvanIsCoding / jogo.cpp
Last active July 11, 2017 15:27
Seletiva IOI 2013
// Ivan Carvalho
// Jogo - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define MAX 10010
#define LIMIT 1000000000
#define F first
#define S second
using namespace std;
@IvanIsCoding
IvanIsCoding / caminho.cpp
Last active July 11, 2017 15:27
Seletiva IOI 2015
// Ivan Carvalho
// Caminho - Seletiva IOI - OBI 2015
#include <bits/stdc++.h>
#define MP make_pair
#define TAMANHO first
#define X second.first
#define Y second.second
#define MAXN 302
using namespace std;
typedef pair<int,int> ii;