不好康的代码:
```
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int ans=-1,ans1;
int h[10][10],l[10][10],hang[10][10];
int a[10][10];
struct FastIO{
int read(){
int x=0,w=0;
char ch=0;
while(!isdigit(ch)) w|=ch=='-',ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return w?-x:x;
}
}io;
#define read io.read
bool jud[10][10];
int sc[10][10]=
{{0,0,0,0,0,0,0,0,0,0},
{0,6,6,6,6,6,6,6,6,6},
{0,6,7,7,7,7,7,7,7,6},
{0,6,7,8,8,8,8,8,7,6},
{0,6,7,8,9,9,9,8,7,6},
{0,6,7,8,9,10,9,8,7,6},
{0,6,7,8,9,9,9,8,7,6},
{0,6,7,8,8,8,8,8,7,6},
{0,6,7,7,7,7,7,7,7,6},
{0,6,6,6,6,6,6,6,6,6}};
void dfs(int x,int y,int score){
if(a[x][y]!=0){
if(x==9&&y==9){
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++)
if(!jud[i][j])
score+=a[i][j]*sc[i][j];
ans=max(ans,score);
return;
}
if(y==9) dfs(x+1,1,score);
else dfs(x,y+1,score);
}
else{
for(int i=1;i<=9;i++){
if(!h[x][i]&&!l[y][i]&&!hang[(x-1)/3*3+(y-1)/3+1][i]){
a[x][y]=i;
h[x][i]=l[y][i]=hang[(x-1)/3*3+(y-1)/3+1][i]=1;
if(x==9&&y==9){
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++)
if(!jud[i][j])
score+=a[i][j]*sc[i][j];
ans=max(ans,score);
return;
}
if(y==9) dfs(x+1,1,score);
else dfs(x,y+1,score);
a[x][y]=0;
h[x][i]=l[y][i]=hang[(x-1)/3*3+(y-1)/3+1][i]=0;
}
}
}
}
int main() {
for(int i=1; i<=9; i++){
// l[i].rank=i;
for(int j=1; j<=9; j++) {
a[i][j]=read();
if(a[i][j]!=0) {
h[i][a[i][j]]=l[j][a[i][j]]=hang[(i-1)/3*3+(j-1)/3+1][a[i][j]]=1;
jud[i][j]=1;
ans1+=a[i][j]*sc[i][j];
}
// else l[i].num++;
}
}
// sort(l+1,l+10);
dfs(1,1,ans1);
printf("%d",ans);
return 0;
}
```
by _stellar @ 2019-02-09 15:04:01
萌新都是怪物系列
by 影子鱼llt @ 2019-02-09 15:05:41
怪物
~~我才是萌新~~
by ousuimei_68 @ 2019-02-09 15:11:24
@[ousuimei_68](/space/show?uid=58319) 您两位别假了,快救我(悲)
by _stellar @ 2019-02-09 15:20:30
QNDMX
WCSMX
QAQ
by t162 @ 2019-02-09 15:25:16
STO `MrWangnacl` OTZ
by FCBM71 @ 2019-02-09 15:42:36