题目大意

  见游戏链接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. 对Map的key按升序进行排序

    //对Map的key按升序进行排序 List<Map.Entry<Integer,Task>> mappingList = new ArrayList<Map.Entry ...

  2. mongodb导入csv

    主要介绍使用自带工具mongoimport工具将 CSV 格式数据导入到 MongoDB 的详细过程. 由于官方提供了mongoimport工具,所以实际上导入 CSV 格式数据的过程非常简单,再次体 ...

  3. jmeter 环境java监视和管理控制

    打开这个小工具的步骤很简单,如果你已经配置好了Jmeter运行的环境,那么你也就不用去做其他的配置,直接 点击:开始——>运行——>输入cmd——>然后在出现的命令行界面输入“jco ...

  4. IIS身份验证和文件操作权限(三、ASP.NET模拟)

    一.配置ASP.NET模拟 注意:在配置[ASP.NET模拟]是还要配置[匿名身份验证]不知道为什么,有知道可以留言,互相学习 二.浏览站点 -- 操作文件 ①无操作权限 点击写入 ②有操作权限(特定 ...

  5. PAT_A1023#Have Fun with Numbers

    Source: PAT A1023 Have Fun with Numbers (20 分) Description: Notice that the number 123456789 is a 9- ...

  6. Matlab转opencv遇到的坑

    之前在学校里面做研究用都是Matlab,后来工作中因为对算法的实时性有很高的要求,所以转向了opencv.我想我遇到的第一大坑就是opencv默认的通道顺序是BGR而不是RGB. 这个顺带的就是灰度化 ...

  7. Feign 系列(02)Why Feign

    Feign 系列(02)Why Feign [toc] 1. 什么是 Feign Feign 的英文表意为"假装,伪装,变形", 是一个 Http 请求调用的轻量级框架,可以以 J ...

  8. linux 上挂载硬盘或者读取u盘数据

    查看服务器上有哪些设备 df -hl查询挂载 硬盘后或者插上u盘后sda 的变化,新增的就是我们添加上的. fdisk -ls /dev/sda

  9. Centos 能ping通域名和公网ip但是网站不能够打开,服务器拒绝了请求。打开80端口解决。

    博客搬迁,给你带来的不便,敬请谅解! http://www.suanliutudousi.com/2017/10/29/centos-%E8%83%BDping%E9%80%9A%E5%9F%9F%E ...

  10. 洛谷 P2652 同花顺(离散化)

    洛谷 P2652 同花顺(题面) 手动模拟了一下,其实离散化排序可以起很大作用题目要求花色相同,数字连续,那么我们要做的就是找一种花色,并提取出其中一串数字留下那些舍弃的牌换成相应花色,并和之前留下的 ...