Skip to content

Instantly share code, notes, and snippets.

View sntea-hogex's full-sized avatar

sntea sntea-hogex

View GitHub Profile
#ifdef LOCAL111
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;
fn getline() -> String{
let mut res = String::new();
std::io::stdin().read_line(&mut res).ok();
res
use std::ops::{Index, IndexMut};
use std::cmp::{Ordering};
use std::collections::BinaryHeap;
use std::cmp::{min, max};
// use std::clone::Clone;
fn getline() -> String{
let mut res = String::new();
std::io::stdin().read_line(&mut res).ok();
res
#ifdef LOCAL111
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define INF 2000000000
#define SZ(a) ((int)a.size())
// #define DEBUG(x) cout << #x << ": " << (x) << endl
// template<typename T>
// void dpite(vector<T> v){
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define INF 2000000000
// #define DEBUG(x) cout << #x << ": " << (x) << endl
// void dpite(vector<int> v){
// REP(i,(int)v.size()) cout << v[i] << ' ';
// cout << endl;
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m;
while(cin >> n >> m and n != 0) {
vector<int> a(n);
for(int i = 0; i < n; ++i) {
@sntea-hogex
sntea-hogex / uf.rs
Created June 6, 2017 16:09
Union-Find
struct UnionFind {
par: Vec<usize>,
rank: Vec<usize>,
}
impl UnionFind {
fn new(n: usize) -> UnionFind {
let mut vec = vec![0;n];
for i in 0..n {
vec[i] = i;
@sntea-hogex
sntea-hogex / solve.cc
Created May 21, 2017 14:44
AOJ 2170 Marked Ancestor
#ifdef LOCAL111
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }
#ifdef LOCAL111
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <bits/stdc++.h>
const long long INF = 1e17;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }