Skip to content

Instantly share code, notes, and snippets.

// Ivan Carvalho
// Xor - Seletiva IOI - OBI 2016
// O(n*log(MAXV))
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3*1e5 + 10;
const int MAXL = 30;
typedef pair<int,int> ii;
@IvanIsCoding
IvanIsCoding / tetris3d.cpp
Created June 15, 2018 11:59
Polish Olympiad in Informatics XIII
// Ivan Carvalho
// Tetris 3D - POI XIII
// O(N*sqrt(S)*sqrt(D))
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int MAXB = 40;
struct decomp{
@IvanIsCoding
IvanIsCoding / Treap.py
Created May 12, 2018 19:44
Treap implementation in Python
# -*- coding : utf-8 -*-
#!/usr/bin/env python3
from random import randint
class TreapNode(object):
def __init__(self,key,priority):
self.key = key
self.priority = priority
// Ivan Carvalho
// Regions - IOI 2009
// O(N*sqrt(Q))
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int MAXN = 2*1e5 + 10;
//Declarando as variáveis
@IvanIsCoding
IvanIsCoding / somaint.cpp
Created February 3, 2018 23:23
Seletiva IOI 2016
// Ivan Carvalho
// Soma de Inteiros - Seletiva IOI - OBI 2016
// O(n*log(ai*N/K))
// Infelizmente esse problema apareceu previamente no Algorithmic Engagements
// Felizmente o link para submeter existe : https://tinyurl.com/somaint2016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll MAXN = 1e6 + 10;
@IvanIsCoding
IvanIsCoding / danone.cpp
Created December 11, 2017 11:01
Seletiva IOI 2017
// Ivan Carvalho
// Danone - Seletiva IOI - OBI 2017
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2*1e6 + 10;
typedef long long ll;
typedef pair<ll,ll> ii;
vector<ii> grafo[MAXN];
int processado[MAXN],raiz[MAXN],pai[MAXN],peso[MAXN],N,Q;
int e1[MAXN],e2[MAXN],e3[MAXN];
@IvanIsCoding
IvanIsCoding / jogo.cpp
Last active December 11, 2017 11:01
Seletiva IOI 2017
// Ivan Carvalho
// Jogo - Seletiva IOI - OBI 2017
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll NEG = -1e17;
struct point{
ll x,y,v;
};
@IvanIsCoding
IvanIsCoding / tribo.cpp
Created December 7, 2017 19:08
Seletiva IOI 2017
// Ivan Carvalho
// Tribo- Seletiva IOI - OBI 2017
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const ll INF = 1e18;
const int MAXN = 1e4 + 10;
const int MAXK = 51;
ll melhor,N,K;
@IvanIsCoding
IvanIsCoding / equipe.cpp
Created December 7, 2017 19:06
Seletiva IOI 2017
// Ivan Carvalho
// Equipe - Seletiva IOI - OBI 2017
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 201;
const int MAXM = 1024;
int mascara[MAXN],antimascara[MAXN],N,K;
int dp[MAXM][MAXM];
int main(){
cin >> N >> K;
@IvanIsCoding
IvanIsCoding / cabo.cpp
Created December 7, 2017 19:04
Seletiva IOI 2017
// Ivan Carvalho
// Cabo- Seletiva IOI - OBI 2017
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 27;
const int ADD = 1251;
const int INF = 10000;
vector<int> v1,v2,temp1[MAXN],temp2[MAXN];
int existe1[MAXN][ADD*2],existe2[MAXN][ADD*2];
int passou1[MAXN][ADD*2][MAXN],passou2[MAXN][2*ADD][MAXN];