Skip to content

Instantly share code, notes, and snippets.

@kusano
kusano / Cyclemin.cpp
Created June 8, 2015 17:45
TopCoder C++11
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
constexpr int f(int a) {return a+a;}
int v[f(10)];
class Cyclemin{public:
string bestmod(string s, int k)
@kusano
kusano / PathDefense.cpp
Created June 8, 2015 17:14
2015 TopCoder Open Marathon - Round 2
// http://community.topcoder.com/longcontest/?module=ViewProblemStatement&compid=48152&rd=16471
#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <cctype>
#include <cstdlib>
#include <numeric>
#include <algorithm>
@kusano
kusano / A.py
Created May 30, 2015 16:38
Google Code Jam 2015 Round 2
def solve(R, C, B):
ans = 0
for cy in range(R):
for cx in range(C):
if B[cy][cx]!=".":
ok = []
for d in range(4):
x = cx
y = cy
while True:
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <shellapi.h>
#include <tchar.h>
#include <locale.h>
#include <cstdio>
#include <vector>
#include <cassert>
#pragma comment(lib, "shell32.lib")
@kusano
kusano / A-small.py
Created May 10, 2015 11:34
Google Code Jam 2015 Round 1C
def check(R,C,W,B):
c = sum(b.count(1) for b in B)
for y in range(R):
for x in range(C-W+1):
if B[y][x:x+W].count(1)==c and B[y][x:x+W].count(-1)==0:
return True
return False
def BT(R,C,W,B):
Bt = tuple(tuple(b) for b in B)
@kusano
kusano / SmallPolygons.cpp
Created May 4, 2015 17:32
2015 TopCoder Open - Round 1
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
class SmallPolygons
{
@kusano
kusano / pointer.cpp
Created April 21, 2015 13:16
メンバ変数への汎用ポインタ
struct A {
int a;
};
int main()
{
A a;
int *p0 = &a.a; // OK
void *p1 = &a.a; // OK
int A::*p2 = &A::a; // OK
@kusano
kusano / pointer.cpp
Last active August 29, 2015 14:19
メンバ変数への汎用ポインタ
struct A {
int a;
};
int main()
{
A a;
int *p0 = &a.a; // OK
void *p1 = &a.a; // OK
int A::*p2 = &A::a; // OK
!function(){
var R = 480;
document.querySelectorAll(".schedule_member_base_grn")[1].style.position="relative";
var p=document.querySelectorAll(".user-grn");
var n=p.length;
for (var i=0;i<n;i++) {
p[i].r = R*Math.sqrt(Math.random());
p[i].th = 2*Math.PI*Math.random();
@kusano
kusano / circle.js
Created March 7, 2015 15:23
ガルーンの予定の参加者を円形に(回転版)
!function(){
function render(){
var t=performance.now()/1000;
document.querySelectorAll(".schedule_member_base_grn")[1].style.position="relative";
var p=document.querySelectorAll(".user-grn");
var n=p.length;
for(var i=0;i<n;i++){
var s=p[i].style;
s.position="absolute";
s.top=48*Math.sin(2*Math.PI*(i/n+t))+"px";