题目大意

  见游戏链接https://store.steampowered.com/app/321480/

分析

  作为一个程序猿,我拒绝用人脑dfs。

代码如下

 #include <bits/stdc++.h>
using namespace std; #define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i) #define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl #define LOWBIT(x) ((x)&(-x)) #define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define UNIQUE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define REMOVE(x, c) x.erase(remove(x.begin(), x.end(), c), x.end()); // 删去 x 中所有 c
#define TOLOWER(x) transform(x.begin(), x.end(), x.begin(),::tolower);
#define TOUPPER(x) transform(x.begin(), x.end(), x.begin(),::toupper); #define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a)) #define MP make_pair
#define PB push_back
#define ft first
#define sd second template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
} template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v)
in >> x;
return in;
} template<typename T>
ostream &operator<<(ostream &out, vector<T> &v) {
Rep(i, v.size()) out << v[i] << " \n"[i == v.size()];
return out;
} template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
out << "[" << p.first << ", " << p.second << "]" << "\n";
return out;
} inline int gc(){
static const int BUF = 1e7;
static char buf[BUF], *bg = buf + BUF, *ed = bg; if(bg == ed) fread(bg = buf, , BUF, stdin);
return *bg++;
} inline int ri(){
int x = , f = , c = gc();
for(; c<||c>; f = c=='-'?-:f, c=gc());
for(; c>&&c<; x = x* + c - , c=gc());
return x*f;
} template<class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
} inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
} //min <= aim <= max
template<typename T>
inline bool BETWEEN(const T aim, const T min, const T max) {
return min <= aim && aim <= max;
} typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< int, PII > PIPII;
typedef pair< string, int > PSI;
typedef pair< int, PSI > PIPSI;
typedef set< int > SI;
typedef set< PII > SPII;
typedef vector< int > VI;
typedef vector< double > VD;
typedef vector< VI > VVI;
typedef vector< SI > VSI;
typedef vector< PII > VPII;
typedef map< int, int > MII;
typedef map< int, string > MIS;
typedef map< int, PII > MIPII;
typedef map< PII, int > MPIII;
typedef map< string, int > MSI;
typedef map< string, string > MSS;
typedef map< PII, string > MPIIS;
typedef map< PII, PII > MPIIPII;
typedef multimap< int, int > MMII;
typedef multimap< string, int > MMSI;
//typedef unordered_map< int, int > uMII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
typedef priority_queue< int > PQIMax;
typedef priority_queue< int, VI, greater< int > > PQIMin;
const double EPS = 1e-;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + ;
const int maxN = 1e5 + ;
const LL ONE = ;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555; struct Point{
int X, Y; Point() {}
Point(int x, int y) : X(x), Y(y) {} Point operator+ (const Point &x) const {
Point ret;
ret.X = X + x.X;
ret.Y = Y + x.Y;
return ret;
} Point operator- (const Point &x) const {
Point ret;
ret.X = X - x.X;
ret.Y = Y - x.Y;
return ret;
}
}; vector< vector< vector< Point > > > type = {
// type #1
// ***
// *
{
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(-, )},
{Point(, ), Point(, ), Point(, ), Point(, )}
},
// type #2
// ***
// *
{
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(-, ), Point(-, )}
},
// type #3
// **
// **
{
{Point(, ), Point(, ), Point(-, ), Point(-, )},
{Point(, ), Point(, ), Point(, ), Point(, )}
},
// type #4
// **
// **
{
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(-, )}
},
// type #5
// ****
{
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(, )}
},
// type #6
// **
// **
{
{Point(, ), Point(, ), Point(, ), Point(, )}
},
// type #7
// *
// ***
{
{Point(, ), Point(, ), Point(, ), Point(-, )},
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(, ), Point(, )},
{Point(, ), Point(, ), Point(-, ), Point(, )}
}
}; int m, n;
int board[][];
MII types;
int cnt; void init() {
Rep(i, type.size()) {
vector< vector< Point > > tmp;
Rep(j, type[i].size()) {
vector< Point > t;
Rep(k, type[i][j].size()) {
if(k == ) continue;
Rep(h, type[i][j].size()) t.PB(type[i][j][h] - type[i][j][k]);
tmp.PB(t);
t.clear();
}
}
foreach(j, tmp) type[i].PB(*j);
tmp.clear();
} /*
Point s(2, 2);
Rep(i, type.size()) {
Rep(j, type[i].size()) {
int b[6][6];
ms0(b);
Rep(k, type[i][j].size()) {
Point tmp = s + type[i][j][k];
b[tmp.X][tmp.Y] = i + 1;
} For(tx, 0, 5) {
For(ty, 0, 5) cout << b[tx][ty];
cout << endl;
}
cout << "**************************************\n";
}
}
*/
} bool check(int x, int y, int i, int j) {
Point s(x, y);
Rep(k, type[i][j].size()) {
Point tmp = s + type[i][j][k];
if(!BETWEEN(tmp.X, , m) || !BETWEEN(tmp.Y, , n) || board[tmp.X][tmp.Y]) return false;
}
return true;
} void print(){
For(i, , m) {
For(j, , n) cout << board[i][j];
cout << endl;
}
cout << "**************************************\n";
} inline void dfs(int x, int y) {
Point s(x, y); Rep(i, type.size()) {
if(!types[i + ]) continue;
Rep(j, type[i].size()) {
if(!check(x, y, i, j)) continue; Rep(k, type[i][j].size()) {
Point tmp = s + type[i][j][k];
board[tmp.X][tmp.Y] = i + ;
}
--types[i + ];
cnt += ; if(cnt == m * n) {
print();
return;
} For(tx, , m) {
For(ty, , n) {
if(!board[tx][ty]) {
dfs(tx, ty);
tx = m;
break;
}
}
} cnt -= ;
++types[i + ];
Rep(k, type[i][j].size()) {
Point tmp = s + type[i][j][k];
board[tmp.X][tmp.Y] = ;
}
}
}
} int main(){
//freopen("MyOutput.txt","w",stdout);
//freopen("input.txt","r",stdin);
//INIT();
init(); cin >> m >> n; // 棋盘规格
For(i, , ) cin >> types[i]; // 每种积木的数量 dfs(, );
return ;
}

最新文章

  1. 基于Twitter-Snowflake的java改进版,去状态化实现
  2. PHP (sendmail / PHPMailer / ezcMailComposer)发送邮件
  3. App开发(Android与php接口)之:短信验证码
  4. Oracle----Job
  5. iOS-多线程--介绍NSOperration
  6. 【BZOJ-3653】谈笑风生 DFS序 + 可持久化线段树
  7. iOS中为网站添加图标到主屏幕
  8. Js练笔——用循环和递归实现追踪对象深度(循环引用关系不考虑)
  9. svg学习(八)polyline
  10. Playmaker Input篇教程之Playmaker购买下载和导入
  11. c++程序编码
  12. github 添加 C# IGNORE
  13. C# 利用TextBox的Text属性实现换行加字符 &quot;\r\n&quot;
  14. Hyper-V连接虚拟机异常,“无法进行连接,因为可能无法将凭据发送到远程计算机”
  15. 李林APUE之进程的封装
  16. ASP.NET Core文件上传与下载(多种上传方式)
  17. linux打印彩色字
  18. dataframe的进行json数据的压平、增加一列的id自增列
  19. 关于js事件执行顺序
  20. [k8s]zookeeper集群在k8s的搭建(statefulset模式)-pod的调度

热门文章

  1. 导出EXCEL(带数据)
  2. 芜湖市2018市队选拔Day2T1
  3. jQuery Validate (1)
  4. Robotframework之下拉列表select
  5. 使用并行ssh提高工作效率
  6. IIS身份验证和文件操作权限(二、匿名身份验证)
  7. Redis启动Sentinel出现警告的解决
  8. adis16405 配置
  9. 机器学习技法笔记:Homework #5 特征变换&amp;Soft-Margin SVM相关习题
  10. Win10下安装erl和RabbitMQ踩坑【版本不兼容】