Skip to content

Instantly share code, notes, and snippets.

@johnchen902
johnchen902 / 240. Square, Diamond, and Rectangle.c
Created September 19, 2015 10:42
Judge Girl - 240. Square, Diamond, and Rectangle
#include <stdio.h>
#include <stdbool.h>
#define SWAP(T, X, Y) \
do { \
T johnchen902_swap_temp = X; \
X = Y; \
Y = johnchen902_swap_temp; \
} while(0)
int main() {
int t;
@johnchen902
johnchen902 / A - Bali Sculptures.cpp
Created May 11, 2015 03:50
APIO 2015 Solution in Code
#include <cstdio>
#include <algorithm>
using namespace std;
int n, a, b;
int y[2000];
long long sum[2001];
bool dp1[101][101];
bool ok1(long long mask) {
@johnchen902
johnchen902 / toi2015-t2-pC.cpp
Created March 31, 2015 16:33
TOI 2015 Test 2 Problem C
#include <cstdio>
#include <cmath>
using namespace std;
double p[100001];
double c[100000];
int main() {
int maxn = 100000;
p[1] = 1;
@johnchen902
johnchen902 / Game_3.cpp
Created March 18, 2015 00:23
IOI 2013 Game
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <memory>
using namespace std;
using ull = unsigned long long;
@johnchen902
johnchen902 / HOJ289.cpp
Created March 17, 2015 02:35
IOI 2013 Wombats (55/100)
#include <cstdio>
#include <limits>
#include <algorithm>
using namespace std;
constexpr int max_r = 5000;
constexpr int max_c = 100;
int r, c;
int h[max_r][max_c - 1];
@johnchen902
johnchen902 / HOJ255.cpp
Created March 15, 2015 06:31
HSNU Online Judge Problem : 255 - Empodia
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
struct Range{
int l, r;
Range(): l(0), r(0) {}
Range(int ll, int rr): l(ll), r(rr) {}
bool empty() const { return l == r; }
@johnchen902
johnchen902 / 1827_3.cpp
Created March 11, 2015 11:03
TIOJ Infor Online Judge Problem 1827. Yet another simple task (Solution Version 3)
#include <cstdio>
#include <algorithm>
using namespace std;
int data[2][128 * 1024];
int left[17][128 * 1024];
/**
* Precondition: data[17 % 2] is b
* Postcondition: left is properly filled
@johnchen902
johnchen902 / TIOJ1827.cpp
Last active August 29, 2015 14:16
TIOJ Infor Online Judge Problem 1827. Yet another simple task
#include <cstdio>
#include <algorithm>
using namespace std;
struct Node {
int sum;
Node *lc, *rc;
Node(int s);
Node(Node*, Node*);
};
@johnchen902
johnchen902 / HOJ226.cpp
Created February 21, 2015 07:50
HSNU Online Judge Problem : 226 - K. CP
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <new>
using namespace std;
struct Tree;
class TreeRef {
@johnchen902
johnchen902 / Foo.java
Last active August 29, 2015 14:15
Suggested Edit
int[] sc = new int[36]; int sum = 0;
for (int i = 0; i < 6; i++)
sc[i * 6 + (5 - i)] = i;
for (int i = 0; i < gC.length; i++) {
for (int j = 0; j < 6; j++) {
sc[j * 6 + t[i]] += j + t[i];
sc[g[i] * 6 + j] -= g[i] + t[i]; } }
for (int m = 0; m < 36; m++) {
if (sc[m] < 1) sc[m] = 1; sc[m] *= sc[m];
sum += sc[m]; }