题目大意

  见游戏链接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 ;
}

Sigils of Elohim的更多相关文章

  1. JavaScript 中的尾调用

    尾调用(Tail Call) 尾调用是函数式编程里比较重要的一个概念,它的意思是在函数的执行过程中,如果最后一个动作是一个函数的调用,即这个调用的返回值被当前函数直接返回,则称为尾调用,如下所示: f ...

  2. elixir 入门笔记

    安装 MAC 平台用 brew 安装 brew update brew install elixir 如果没有 erlang 环境,上面的命令会自定安装 erlang 的环境. 基本数据类型 iex& ...

  3. Perl monks 的 快速回复

    on Jun 20, 2019 at 11:39 UTC ( #11101620=perlquestion: print w/replies, xml ) Need Help?? jimyokl ha ...

随机推荐

  1. [Android开发] 代码code设置9.png/9-patch 图片背景后,此view中的TextView等控件显示不正常(常见于listview中)

    == 0) { convertView.setBackgroundResource(R.drawable.list_gray_9); } else { convertView.setBackgroun ...

  2. js面向对象编程(第2版)——js继承多种方式

    附带书籍地址: js面向对象编程(第2版)

  3. error LNK2001: 无法解析的外部符号 __imp__MessageBoxA@16

    错误: error LNK2001: 无法解析的外部符号 __imp__MessageBoxA@16 原因: 本来程序的编译选项选择的是:使用标准windows库,当改为在静态库中使用MFC后就出现了 ...

  4. 1.6 flux介绍

    这一节将介绍 React 的核心应用架构模式 Flux,包括内容: Flux 介绍 MVC 架构之痛 Flux 的理解 Flux 相关库和工具介绍 Flux 与 React 实例 最后我们将会把之前的 ...

  5. zabbix4.0自动注册实践

    共分为两个步骤: 1.主机zabbix_agent客户端的配置文件 2.主机zabbix_server网页端的自动注册配置 zabbix_agent配置文件 Server=192.168.100.15 ...

  6. Zabbix监控搭建

    目录 Zabbix概述        zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案 ( 基于 GPL V2 )zabbix由 2 部分构成,zabbix ...

  7. MFS分布式文件系统【2】MFS MASTER 部署

    MFS版本 mfs-1.6.27 MFS-MASTER 192.168.1.190 MFS-CHUNKSERVER1 192.168.1.252 MFS-CHUNKSERVER2 192.168.1. ...

  8. hud 3183

    题意:给出n个数字的字符串,要求你删除m个数字后,得到的数字最小. 分析:删除m个,就是选n-m个,而且,选的第一个数,肯定在(0—(n-m-1))中,第二个就在(第一个的下一位—(n-m-2)中.就 ...

  9. usb-host与外设通信(三)

    4.与设备之间的通信 和USB设备通信可以是同步的或者是异步的,无论是哪一种情况,你都应该创建一个新的线程来处理数据传输,这样才不会使UI线程出现阻塞.与设备建立适宜的通信,你需要获得该设备一个合适的 ...

  10. 原型对象(JS中的父类)

    原型 prototype 我们所创建的每一个函数,解析器都会向函数中添加 一个属性prototype ,这个属性对应的对象就是我们所谓的原型对象  判断函数中是否含有prototype属性,有则返回 ...