Skip to content

Instantly share code, notes, and snippets.

@IvanIsCoding
IvanIsCoding / picture.cpp
Last active December 9, 2017 13:01
IOI 1998
// Ivan Carvalho
// Picture - International Olympiad in Informatics 1998
// ioi98p4 - https://dmoj.ca/problem/ioi98p4
// O(n*log(n))
#include <bits/stdc++.h>
#define MT make_tuple
using namespace std;
typedef tuple<int,int,int,int> quadra;
const int MAXN = 20100;
const int ADD = 10001;
@IvanIsCoding
IvanIsCoding / pedrasonline.cpp
Last active December 11, 2017 13:45
Seletiva IOI 2015
// Ivan Carvalho
// Pedras - Seletiva IOI - OBI 2015
// Alternative Solution - O(n*sqrt(n))
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int BUCKET = 318;
vector<int> ida;
int freq[BUCKET][MAXN],tempfreq[MAXN],versao[MAXN],divisao[MAXN],vetor[MAXN],iteracao,N,Q;
int precalc[BUCKET][BUCKET];
@IvanIsCoding
IvanIsCoding / doodle.cpp
Created July 15, 2017 20:27
Seletiva IOI 2015
// Ivan Carvalho
// Doodle - Seletiva IOI - OBI 2015
// O(n*log^2(n))
#include <bits/stdc++.h>
#define MP make_pair
#define F first
#define S second
#define LSOne(S) (S & (-S))
using namespace std;
typedef pair<int,int> point;
@IvanIsCoding
IvanIsCoding / marsmap.cpp
Created July 14, 2017 14:58
Baltic Olympiad in Informatics 2001
// Ivan Carvalho
// Mars Map - Baltic Olympiad in Informatics 2001
// NKMARS - http://www.spoj.com/problems/NKMARS/
// O(n*log(n))
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef pair<int,int> i2;typedef pair<int,i2> i3;typedef pair<int,i3> i4;
const int MAXN = 3*1e4 + 10;
vector<i4> sweep;
@IvanIsCoding
IvanIsCoding / papel.cpp
Created July 13, 2017 01:20
Solução OBI 2017
// Ivan Carvalho
// Cortando o Papel - Fase 2 Programação Nível 2 - OBI 2017
// O(n*log(n))
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
vector<ii> papel;
int estado[100010],n,tiras,resp;
int main(){
scanf("%d",&n);
@IvanIsCoding
IvanIsCoding / energia.cpp
Created July 11, 2017 15:29
Seletiva IOI 2016
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
inline bool compara(ii x,ii y){return x.first > y.first;}
vector< vector<ii> > pai,valores;
vector<int> peso;
vector<iii> Kruskal;
int find(int x,int kth){
@IvanIsCoding
IvanIsCoding / parallel.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2007
// Ivan Carvalho
// Paralelogramo - Seletiva IOI - OBI 2007
// O(n^2 * log(n))
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
map<ii, map<double,int> > tab;
map<ii,int > special;
map<ii,int> freq;
int X[1001],Y[1001];
@IvanIsCoding
IvanIsCoding / tatu.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Tatu - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
#define MAXN 261
#define INF 1010
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
int matriz[MAXN][MAXN],acumulada[MAXN][MAXN],linear[MAXN];
@IvanIsCoding
IvanIsCoding / cantores.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Cantores - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MAXN 100010
#define MP make_pair
#define F first
#define S second
using namespace std;
typedef pair<char,char> cc;
typedef pair<cc,cc> c4;
@IvanIsCoding
IvanIsCoding / passeio.cpp
Last active July 11, 2017 15:22
Seletiva IOI 2013
// Ivan Carvalho
// Passeio - Seletiva IOI - OBI 2013
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef struct node* pnode;
typedef vector<ll>::iterator ite;
const ll MAXN = 1e5 + 10;