Skip to content

Instantly share code, notes, and snippets.

@phonism
phonism / Tour de Byteotia.cpp
Last active December 23, 2015 02:09
http://main.edu.pl/en/archive/oi/19/tou 19th Polish Olympiad in Informatics Stage II - day 0
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 1001000;
const int maxm = 2002000;
@phonism
phonism / Vouchers.cpp
Last active December 23, 2015 02:38
www.main.edu.pl/en/user.phtml?op=showtask&task=bon&con=OI19 19th Polish Olympiad in Informatics Stage II - day 1
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 1000011;
int n, m, x, maxm, a[maxn], pos[maxn];
@phonism
phonism / sgu499.cpp
Created September 16, 2013 07:12
SGU 499. Greatest Greatest Common Divisor http://acm.sgu.ru/problem.php?contest=0&problem=499
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 1000010;
int n, maxx, a[100100], pos[maxn];
@phonism
phonism / hdu2426.cpp
Created September 16, 2013 08:28
HDU 2426 Interesting Housing Problem http://acm.hdu.edu.cn/showproblem.php?pid=2426 最小费用最大流
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define maxn 2110
#define maxm 2000001
@phonism
phonism / poj2195.cpp
Created September 16, 2013 08:52
POJ 2195 Going Home http://poj.org/problem?id=2195 最小费用最大流
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
#define maxn 2110
@phonism
phonism / CF249E.cpp
Created September 16, 2013 17:04
Codeforces 249 E. Tree-String Problem http://codeforces.com/problemset/problem/291/E dfs+kmp
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int maxn = 100100;
@phonism
phonism / CF296B.cpp
Created September 16, 2013 19:47
Codeforces 296 B. Yaroslav and Two Strings http://codeforces.com/problemset/problem/296/B 容斥原理
/*
a[i],b[i],c[i],d[i]分别表示 、ch1[i]<=ch2[i]的情况数、
ch1[i]>=ch2[i]的情况数、ch1[i]==ch2[i]的情况数看,
所有的情况数。那么根据容斥原理,
有ans = sum(d) - sum(a) - sum(b) + sum(c)
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
@phonism
phonism / CF3D.cpp
Created September 17, 2013 00:29
Codeforces 3D. Least Cost Bracket Sequence http://codeforces.com/problemset/problem/3/D 优先队列
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
priority_queue<pair<long long, long long> > q;
string str;
@phonism
phonism / POJ3468.cpp
Created September 17, 2013 21:01
POJ 3468 A Simple Problem with Integers http://poj.org/problem?id=3468 树状数组维护区间加减,区间求和
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 100100;
char op[10];
@phonism
phonism / CF341D.cpp
Created September 17, 2013 21:14
Codeforces 341D. Iahub and Xors http://codeforces.com/problemset/problem/341/D 2D树状数组
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 1031;
int n, m, op, x1, y1, x2, y2;