hiho week 100 register

Ended

Participants:432

Verdict:Accepted
Score:100 / 100
Submitted:2016-05-29 21:50:27

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <utility>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <cassert>
using namespace std;
typedef int Status[10];
typedef pair<int, int> PII;
int f[362880];
int g[362880];
int delta[] = {-1, 1, -3, +3};
int h(Status s){
    int ret = 0;
    for(int i = 1; i <= 9; i++){
        int r1 = (i - 1) / 3;
        int c1 = (i - 1) % 3;
        int v = s[i];
        if(v == 9)  continue;
        int r2 = (v - 1) / 3;
        int c2 = (v - 1) % 3;
        ret += (r1 > r2 ? r1 - r2: r2 - r1) + (c1 > c2? c1 - c2: c2 - c1);
    }
    return ret;
}
int cantor(Status s){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX