Skip to content

Instantly share code, notes, and snippets.

View ichyo's full-sized avatar

ichyo ichyo

  • Tokyo, Japan
View GitHub Profile

以下の変更をして50%の確率で11000点が出るようになった

  • Campaing を1にする
  • Categoryは不変なのでオンメモリにする
  • items に (created_at) の インデックスを貼る
  • itemsdescription が大きいので不要なところではSELECTに入れないようにする
  • nginx+app without login, mysql, app for login の3台に分ける
  • 同じ商品を買う人のLock待ちが多すぎて死なないように db.SetMaxOpenConns に適切な数を与える
  • 同じ商品を買う人の大量アクセスをさばくために nginx の設定を色々変える

以下の変更ができなかったので0点になって予選に落ちた

@ichyo
ichyo / open.rs
Last active January 22, 2018 07:59
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
fn open<P: AsRef<Path>>(path: P) -> Result<std::io::Lines<BufReader<File>>, std::io::Error> {
let file = File::open(path)?;
let reader = BufReader::new(file);
Ok(reader.lines())
}
@ichyo
ichyo / wrong_answer
Last active July 10, 2022 20:16
競技プログラミングにおけるWrong Answerの原因ビンゴ
1: i, jの書き違い (例: for(int i = 0; i < n; i++) for(int j = 0; j < m; i++) )
2: 問題文の読み違え
3: 変数名の重複
4: 提出するコードを間違える
5: 初期化忘れ
6: 計算量の見誤り
7: builtin関数の未定義動作 (例: __builtin_ctz(0) )
8: 二分探索の最大値・最小値の見誤り
9: forの++,--を逆にする (例: for(int i = n - 1; i >= 0; i++) )
10: long longなのにint用の関数を使う
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
const double EPS = 1e-8;
const int INF = 100000000;
using namespace std;
struct Point{
int x, y, z;
@ichyo
ichyo / markov.py
Created January 3, 2013 13:21
マルコフ連鎖で文章作るねん
#!/usr/bin/env python
# coding: utf-8
import os
import sys
import re
from collections import defaultdict
import random
def split(sentence):
@ichyo
ichyo / gist:4351662
Created December 21, 2012 09:13
iris data from R language
7.000000 4.700000 1
6.400000 4.500000 1
6.900000 4.900000 1
5.500000 4.000000 1
6.500000 4.600000 1
5.700000 4.500000 1
6.300000 4.700000 1
4.900000 3.300000 1
6.600000 4.600000 1
5.200000 3.900000 1
@ichyo
ichyo / gist:4351554
Created December 21, 2012 08:56
cats data from R language
2.000000 7.000000 -1
2.000000 7.400000 -1
2.000000 9.500000 -1
2.100000 7.200000 -1
2.100000 7.300000 -1
2.100000 7.600000 -1
2.100000 8.100000 -1
2.100000 8.200000 -1
2.100000 8.300000 -1
2.100000 8.500000 -1
=begin
prime = Array.new
count = 1
prime[0] = 2
prime[1] = 3
no = 5
sum = 5
while no<2000000
for i in (1..count)
break if (no % prime[i] == 0)
=begin
prime = Array.new
count = 1
prime[0] = 2
prime[1] = 3
no = 5
sum = 5
while no<2000000
for i in (1..count)
break if (no % prime[i] == 0)
prime = Array.new
count = 1
prime[0] = 2
prime[1] = 3
no = 5
while count<10000 do
for i in (1..count)
break if (no % prime[i] == 0)
end
if (i == count)