hiho week 102 register

Ended

Participants:235

Verdict:Accepted
Score:100 / 100
Submitted:2016-06-11 21:22:15

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
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int t;
int sudo[10][10];
bool row[10][10];
bool col[10][10];
bool block[10][10];
bool dfs(int x,int y)  
{
    if(x == 9)  return true;
    if(y == 9)  return dfs(x+1, 0);
    if(sudo[x][y])  return dfs(x, y+1);
    int k = 3*(x/3) + y/3 + 1;
    for(int i = 1; i <= 9; i++)
        if(!row[x][i] && !col[y][i] && !block[k][i]){
            sudo[x][y] = i;
            row[x][i] = true;
            col[y][i] = true;
            block[k][i] = true;
            if(dfs(x,y+1))  return true;
            else{
                sudo[x][y] = 0;
                row[x][i] = false;  
                col[y][i] = false;  
                block[k][i] = false;
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX