博客
关于我
cf 1104c 思维
阅读量:312 次
发布时间:2019-03-03

本文共 849 字,大约阅读时间需要 2 分钟。

题意:

要求将输入的所有1×2或2×1方块填入4×4的格子中,确保方块不重叠,并满足以下条件:若某行或某列有方块,则可以消除该行或列中的方块。

题解:

1. 遇到水平方块时,填入位置(1,1); 2. 遇到垂直方块时,填入位置(3,3); 3. 若目标位置已被占据,则填入(1,3)。
#include 
#define N 800005 using namespace std; int main(){ int i, j, k; char s[1005]; int len; bool vis[10][10]; memset(vis, 0, sizeof(vis)); scanf("%s", s); len = strlen(s); for(i = 0; i < len; i++){ if(s[i] == '0'){ if(!vis[3][3]){ vis[3][3] = 1; printf("3 3\n"); }else{ vis[3][3] = 0; printf("1 3\n"); } }else{ if(!vis[1][1]){ vis[1][1] = 1; printf("1 1\n"); }else{ vis[1][1] = 0; printf("1 3\n"); } } } }

转载地址:http://dpml.baihongyu.com/

你可能感兴趣的文章
postman的使用
查看>>
Postman的使用说明
查看>>
Postman被低估的功能 — 自动化接口测试
查看>>
Postman被低估的功能 — 自动化接口测试
查看>>
Postman轻松签名,让SHA256withRSA保驾护航
查看>>
Postman还能做Mock?又学了一招!
查看>>
Postman还能做Mock?又学了一招!
查看>>
postman进行http接口测试
查看>>
Postman高阶技能:Collection集合批量运行!
查看>>
postMessage跨标签页共享数据
查看>>
QImage对一般图像的处理
查看>>
post为什么会发送两次请求?
查看>>
Post表单提交TextArea的值出现转译乱码问题 - Spring MVC处理表单提交
查看>>
Power BI 中的 Python 可视化需要什么设置?任何特定的 matplotlib 包版本或系统设置?
查看>>
Power BI:如何在 Power Query 编辑器中将 Python 与多个表一起使用?
查看>>
power english (3) main text -emotion mastery - focus
查看>>
POWER ENGLISH (6) - MODEL
查看>>
power english (1) —— passion
查看>>
Power English (1) 原文
查看>>
power English (3)原文
查看>>