- 论坛徽章:
- 7
|
本帖最后由 rubyish 于 2017-10-15 18:21 编辑
回复 25# 523066680
bijiaole zhege sudoku17.txt:
dance 3s, lines 600
no dance 49.668, lines 300
code de shuliang zhiyou 2 bei,
dan sudu jingran gaoda 16.5 bei.
dance guoran mingbuxuchuan!
3Q~~ floor25, very good de fenxi!!
zhendui 44227 you yige small OPT, sudu dayue tishenle 8 ~ 10 bei.
- my $slow_44227 = [
- [ 2, 0, 0, 5, 0, 0, 0, 8, 0 ],
- [ 0, 0, 1, 0, 2, 0, 0, 0, 0 ],
- [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
- [ 0, 7, 0, 0, 0, 8, 0, 0, 0 ],
- [ 0, 0, 3, 0, 0, 0, 0, 2, 0 ],
- [ 0, 0, 0, 0, 7, 0, 6, 0, 0 ],
- [ 6, 0, 0, 2, 0, 0, 0, 0, 1 ],
- [ 0, 4, 0, 0, 0, 0, 7, 0, 0 ],
- [ 0, 0, 0, 3, 0, 0, 0, 0, 0 ],
- ];
复制代码
perl: old 1m58.981s, new 0m7.008s
gcc[-Ofast]: old 0m0.673s, new 0m0.082s
sudoku_nd0.txt, sudoku_nd1.txt hui bijiao man
sudoku_nd3.txt, sudoku_nd4.txt sudu ying you dafudude tishen?
new sub best:
- int best (){
- int min = 10;
- int Magic = 10;
- int best = OK;
- int posisi = Head;
- for (int head = Head; head < Tail; head++) {
- Ijk *w = &Dit[head];
- int this = Verti[w->v] | Horiz[w->h] | Bloke[w->b];
- if (this == ERROR) return ERROR;
- int maybe = Maybe[this][OK];
- int that = Verti[w->v] & Horiz[w->h] & Bloke[w->b];
- int magic = Maybe[that][OK];
- if (min > maybe) {
- posisi = head, best = this,Magic = magic;
- if (maybe == BEST) break;
- min = maybe;
- } else if (min == maybe && Magic < magic) {
- posisi = head, best = this, Magic = magic;
- }
- }
- Ijk dat = Dit[posisi];
- Dit[posisi] = Dit[Head];
- Dit[Head++] = dat;
- return best;
- } /* best */
复制代码
|
|