More Related Content
Similar to Code iq interpretation_futatsugi
Similar to Code iq interpretation_futatsugi (8)
More from Fixstars Corporation
More from Fixstars Corporation (20)
Code iq interpretation_futatsugi
- 2. 自己紹介
二木紀行
Twitter: @foota
ブログ「良いもの。悪いもの。」
http://handasse.blogspot.com/
現職・フィックスターズ
ビッグデータ・機械学習アルゴリズム
並列処理・高速化・メニーコア
GPGPU, Xeon Phi, Tileraなど
前職・理化学研究所
薬学 / 創薬の研究
分子動力学(MD)・分子軌道法(MO)
MD専用機MDGRAPE-3・スーパーコンピュータ「京」
競技プログラミング
TopCoderやICFPCなどに参加
- 4. zero-fillの解のスコア
vertical : 246000 / 246000
horizontal: 246000 / 246000
3*3 block : 137780 / 248004
total : 629780 / 740004
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
3 1 2 6 4 5 9 7 8
6 4 5 9 7 8 3 1 2
9 7 8 3 1 2 6 4 5
2 3 1 5 6 4 8 9 7
5 6 4 8 9 7 2 3 1
8 9 7 2 3 1 5 6 4
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
...................................
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
0000000000000000...0000000000000000
1234567891234567...8912345678912345
4567891234567891...2345678912345678
7891234567891234...5678912345678912
3126459783126459...7831264597831264
6459783126459783...1264597831264597
9783126459783126...4597831264597831
2315648972315648...9723156489723156
5648972315648972...3156489723156489
...................................
2315648972315648...9723156489723156
5648972315648972...3156489723156489
8972315648972315...6489723156489723
1234567891234567...8912345678912345
4567891234567891...2345678912345678
7891234567891234...5678912345678912
3126459783126459...7831264597831264
6459783126459783...1264597831264597
- 5. zero-fillの解にtestcaseを入れたスコア
vertical : 59241 / 246000 -186759
horizontal: 58922 / 246000 -187078
3*3 block : 33459 / 248004 -104321
total : 151622 / 740004 -478158
0909000050000000...0000000000000000
0006000000000000...0800000000000000
0000000000200000...0000691100070004
0054260200300300...0000000000000000
0006000045000038...9110800500060030
0100700090000000...0000000900470000
0010000000000070...0397000000000000
6000000006000000...0000000000000000
...................................
0000600000400000...0600000007500400
0010074000000000...7000004009000200
0006002000000800...0050300000001000
0000000308010000...0000000030000280
0000000000004060...0000500000000000
0000200000040000...0100000010200000
0006060000800000...0007030000009000
0050000000080000...0000000250002000
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
3 1 2 6 4 5 9 7 8
6 4 5 9 7 8 3 1 2
9 7 8 3 1 2 6 4 5
2 3 1 5 6 4 8 9 7
5 6 4 8 9 7 2 3 1
8 9 7 2 3 1 5 6 4
1939567851234567...8912345678912345
4566891234567891...2845678912345678
7891234567291234...5678691145678914
3154269283326359...7831264597831264
6456783145459738...9114897531264537
9183726499783126...4597831964477831
2315648972315678...9397156489723156
6648972316648972...3156489723156489
...................................
2315648972415648...9623156487523456
5618974315648972...7156484729156289
8976312648972815...6459323156481723
1234567398214567...8912345638912285
4567891234564861...2345578912345678
7891234567841234...5178912315278912
3126469783826459...7837234597839264
6459783126489783...1264597251262597
- 6. 焼き鈍したスコア
vertical : 95740 / 246000 +36499
horizontal: 96472 / 246000 +37550
3*3 block : 31604 / 248004 -1855
total : 223816 / 740004 +72194
1939567851234567...8912345678912345
4566891234567891...2845678912345678
7891234567291234...5678691145678914
3154269283326359...7831264597831264
6456783145459738...9114897531264537
9183726499783126...4597831964477831
2315648972315678...9397156489723156
6648972316648972...3156489723156489
...................................
2315648972415648...9623156487523456
5618974315648972...7156484729156289
8976312648972815...6459323156481723
1234567398214567...8912345638912285
4567891234564861...2345578912345678
7891234567841234...5178912315278912
3126469783826459...7837234597839264
6459783126489783...1264597251262597
2949816753294861...1792354681792354
4876123594867213...4825796134285796
7231589467231589...2678691145673644
1954267219389327...3854127693854127
5876231945815438...9119834572169834
3126745893126745...6463569969476569
8915374628953176...8397245618397217
6748952316748952...7531986427531986
...................................
2382656837492156...1626843197526413
4618374295684371...7235794859617236
1756592614375892...9854312768951342
8219465378219465...4712685934176285
5834716592834769...2369578412369574
9547238169547238...8178496311298698
3436965743812965...5947231685749231
6958147326985147...6893471256832457
- 7. 全てのマスでナンプレ化のチェック
0 : 000000000
1 : 000000001
2 : 000000010
3 : 000000100
4 : 000001000
5 : 000010000
6 : 000100000
7 : 001000000
8 : 010000000
9 : 100000000
数字をビットで表現すれば、論理和だけでナンプレ化
のチェックができる。
ナンプレ化のチェックの際、数字がバラバラであるほ
どスコアを高くする。
ナンプレ化していればさらにスコアを上乗せする。
- 11. 並列化に関わるソースコード抜粋
class CalcCells {
private:
const double t;
const vector<unsigned int>& cells0;
vector<unsigned int>& cells;
double probability(double e0, double e, double t) const {
return e0 > e ? exp((1.0 - e0 / e) / t) : 1.0;
}
unsigned int get_cell(int x, int y, double t) const {
/* (変数省略) */
vector<unsigned int> bits_list;
// 処理するマスをbits_listに入れる.
/* (処理省略) */
for (unsigned int n = 1; n & 0x01ff; n <<= 1) {
int cnt = 0;
for (vector<unsigned int>::iterator p = bits_list.begin(); p != bits_list.end(); ++p) {
int ct = bitcount[*p | n];
cnt += ct;
if (ct == 9) cnt += W;
}
if (probability(prev_cnt, cnt, t) > static_cast<double>(xor128()) / MY_RAND_MAX) {
best_n = n;
prev_cnt = cnt;
if (cnt > max_cnt) max_cnt = cnt;
}
}
return best_n;
}
public:
CalcCells(const double t_, const vector<unsigned int>& cells0_, vector<unsigned int>& cells_)
: t(t_), cells0(cells0_), cells(cells_) { }
void operator()(const blocked_range2d<int, int>& r) const {
for (int y = r.rows().begin(); y != r.rows().end(); y++)
for (int x = r.cols().begin(); x != r.cols().end(); x++)
if (cells0[y*N+x] == 0) cells[y*N+x] = get_cell(x, y, t);
}
};
parallel_for(blocked_range2d<int, int>(0, N, NDIV, 0, N, NDIV), CalcCells(n * ALPHA, cells0, cells));