```
#locate HEADLINE
#define Plaese Please
```
by 替罪羊树 @ 2018-10-26 18:46:34
没教练没队友。。(可怜楼主在哪里啊?)
我虽然也在小地方但还是有教练队友的,
抱歉我太菜了看不来你的代码
by 云汨汩 @ 2018-10-26 18:59:18
@[一氧气就出错](/space/show?uid=124160) 谢谢了QAQ
by Gae_Blog @ 2018-10-27 19:09:21
Please correct your headline.
by rts_GOD @ 2018-10-29 19:41:37
Me too!!!!!
```
#include<bits/stdc++.h>
using namespace std;
namespace macros{
#define whint register int
#define empty(x,y) (!a[x][y].val)
#define rch getchar()
#define wch putchar
#define pos(Arr,Ptr) Arr[Ptr]
#define setpos1(Arr,Ptr) Arr[Ptr]=1
#define setpos0(Arr,Ptr) Arr[Ptr]=0
#define npos string::npos
}
using namespace macros;
namespace constants{
const int _=0;
const int X=10;//不破坏美观
const int score[10][10]=
{
{_,6,6,6,6,6,6,6,6,6},
{_,6,7,7,7,7,7,7,7,6},
{_,6,7,8,8,8,8,8,7,6},
{_,6,7,8,9,9,9,8,7,6},
{_,6,7,8,9,X,9,8,7,6},
{_,6,7,8,9,9,9,8,7,6},
{_,6,7,8,8,8,8,8,7,6},
{_,6,7,7,7,7,7,7,7,6},
{_,6,6,6,6,6,6,6,6,6}
};
}
using namespace constants;
namespace variable_and_bitset{
struct intok{
int val;
int ok[15];
};
intok a[15][15];
intok tmp[15][15];
inline void cover(int& x,int& y){
for(int i=1;i<=9;++i)
setpos0(a[x][y].ok,a[x][i].val);
for(int i=1;i<=9;++i)
setpos0(a[x][y].ok,a[i][y].val );
}
inline void cover_all(){
for(int i=1;i<=9;++i)
for(int j=1;j<=9;++j)
cover(i,j);
}
int maxn;
}
using namespace variable_and_bitset;
inline int cnt(){
int tot=0;
for(whint i=1;i<=9;++i)
for(whint j=1;j<=9;++j)
tot+=score[i][j]*a[i][j].val;
return tot;
}
inline size_t getx(){
for(whint i=1;i<=9;++i)
for(whint j=1;j<=9;++j)
if(empty(i,j))return i;
return npos;
}
inline size_t gety(){
for(whint i=1;i<=9;++i)
for(whint j=1;j<=9;++j)
if(empty(i,j))return j;
return npos;
}
inline bool ok(int& v,int& xx,int& yy){
for(whint i=1;i<=9;++i)
if(a[xx][i].val==v)return false;
for(whint i=1;i<=9;++i)
if(a[i][yy].val==v)return false;
return true;
}
inline void setcross0(int&,int&,int&);
inline void dfs();
/*******DEBUG*******/
auto printa=//lambda
[]()->void{
cout<<"VVVVVVVVV\n";
for(int i=1;i<=9;++i){
for(int j=1;j<=9;++j)
cout<<a[i][j].val;
cout<<endl;
}
cout<<"AAAAAAAAA\n\n";
};
/*******DEBUG*******/
/*********************************/
namespace quick{
int read(int& xx){
char ch=rch;int sign=1,x=0;
while(!isdigit(ch)&&ch!='-')
ch=rch;
if(ch=='-'){
sign=-1;ch=rch;
}
while(isdigit(ch)){
x=x*10+ch-'0';ch=rch;
}
return xx=sign*x;
}
void write(int x){
printf("%d",x);
}
}
int main(){
for(whint i=1;i<=9;++i)
for(whint j=1;j<=9;++j)
quick::read(a[i][j].val);
cover_all();
dfs();
quick::write(maxn);putchar('\n');
return 0;
}
/*********************************/
inline void dfs(){
#ifdef debug
printa();
#endif
int x=getx(),y=gety();//npos:all filled
if(x==npos||y==npos){
maxn=max(maxn,cnt());
return;
}
for(int i=1;i<=9;++i){
if(pos(a[x][y].ok,i)>0){
memcpy(tmp,a,sizeof(a));
a[x][y].val=i;
setcross0(x,y,i);
dfs();
memcpy(a,tmp,sizeof(tmp));
//a[x][y]=0;
}
}
}
inline void setcross0(int& xx,int& yy,int& ed){
for(int i=1;i<=9;++i)
setpos0(a[xx][i].ok,ed),
setpos0(a[i][yy].ok,ed);
setpos1(a[xx][yy].ok,ed);
}
```
by 持之以珩 @ 2019-01-25 23:50:59
namespace:方便折叠(我用dev-c++)
by 持之以珩 @ 2019-01-25 23:51:47