本人不会解题,直接上代码!

#include <bits/stdc++.h>
using namespace std;
const int LENGTH = (1 << 20);
inline int nextChar()
{static char buffer[LENGTH], *p = buffer, *end = buffer;if (p == end) {if ((end = buffer + fread(buffer, 1, LENGTH, stdin)) == buffer) return EOF;p = buffer;}return *p++;
}
inline bool nextInt(int &x)
{static char negative = 0, c = nextChar();negative = 0, x = 0;while ((c < '0' || c > '9') && c != '-'){ if (c == EOF) return false; c = nextChar(); }if (c == '-') { negative = 1; c = nextChar(); }do x = (x << 3) + (x << 1) + c - '0'; while ((c = nextChar()) >= '0');if (negative) x = -x;return true;
}
int cache[1 << 16], offset[4][2] = {{0, 1}, {1, 0}, {1, 1}, {1, -1}};
int dfs(int x)
{if (~cache[x]) return cache[x];for (int i = 0; i < 16; i++){if (x & (1 << i)) continue;int r = i / 4, c = i % 4;for (int j = 0; j < 4; j++){int bit = 0;for (int k = 0; k < 3; k++){int rr = r + offset[j][0] * k, cc = c + offset[j][1] * k;if (rr < 0 || rr > 3 || cc < 0 || cc > 3) break;if (x & (1 << (rr * 4 + cc))) break;bit |= (1 << (rr * 4 + cc));if (!dfs(x ^ bit)) return cache[x] = 1;}}}return cache[x] = 0;
}
int matrix[16] = {0, 4, 1, 8, 5, 2, 12, 9, 6, 3, 13, 10, 7, 14, 11, 15};
int main(int argc, char *argv[])
{cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);memset(cache, -1, sizeof(cache));cache[(1 << 16) - 1] = 0;int cases;nextInt(cases);for (int cs = 1; cs <= cases; cs++){int mask = 0, cnt = 0;char character;while (cnt < 16){character = nextChar();if (character == '*' || character == '.'){if (character == '*')mask |= (1 << matrix[cnt]);cnt++;}}cout << (dfs(mask) ? "Possible." : "Impossible.") << '\n';}return 0;
}

让人春分日 哈工科教115166.弹珠游戏相关推荐

  1. 让人春分日 哈工科教100272.关路灯

    一如既往的答案! #include <iostream> #include <cstring> #include <algorithm> using namespa ...

  2. 让人春分日 哈工科教100798.宇宙总统

    #include <bits/stdc++.h> using namespace std; int n,m; int main() {string p,max;cin >> n ...

  3. 让人春分日 哈工科教101414.集合求和

    #include<iostream> using namespace std; int main() {int i;int sum=0,n=0;while(cin>>i){su ...

  4. 让人春分日 哈工科教110132.平面分割

    #include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){int n,p;ll res; ...

  5. springboot日结工管理小程序毕业设计-附源码070940

    摘  要 信息化社会内需要与之针对性的信息获取途径,但是途径的扩展基本上为人们所努力的方向,由于站在的角度存在偏差,人们经常能够获得不同类型信息,这也是技术最为难以攻克的课题.针对日结工管理等问题,对 ...

  6. 五险一金真的那么重要吗?为什么很多人宁愿做小时工不要五险一金?

    五险一金非常重要,至于很多人宁愿做小时工也不要五险一金,是由很多因素决定的. 首先,说一下五险一金是什么. 五险一金包括五险和一金,五险就是社保,包括养老.医疗.失业.生育.工伤保险:一金指住房公积金 ...

  7. 华为云开发者日KooLabs工作坊走进北京物资学院

    摘要:近日华为云开发者日KooLabs工作坊活动在北京物资学院成功举办. 本文分享自华为云社区<华为云开发者日KooLabs工作坊走进北京物资学院>,作者:华为云社区精选 . 近日华为云开 ...

  8. 13 登陆_《星球大战:弹珠台》中文版即将登陆Switch 12月13日正式发售

    日前,发行商Game Source Entertainment宣布,由Zen Studios开发<星球大战:弹珠台>Switch简/繁体中文版,将在12月13日正式发售. 本作是第一款将于 ...

  9. 6月1日起,未接入防沉迷系统的游戏将停止运营(附详细接入流程)

    业内传来消息,版署近日在组织游戏企业培训防沉迷系统接入,并传达了防沉迷接入工作时间节点要求. 其中提到,2021年5月31日前,所有游戏企业需完成在运营游戏的防沉迷系统的接入工作.6月1日起,未接入防 ...

最新文章

  1. Spring整合rabbitmq---消息接收
  2. pytorch 测试 darknet
  3. Windows Azure Cloud Service (27) 在Windows Azure发送邮件(上)
  4. PHP7.0 Window10 Redis安装教程
  5. 程序员修神之路--redis做分布式锁可能不那么简单
  6. 为什么我不推荐Python初学者直接看项目源码?工作五年的程序员给的忠告
  7. 云计算能给你带来什么?
  8. 使用runtime跳转界面
  9. Luogu2627 修剪草坪
  10. Python中终端彩色打印输出
  11. 机房重构-panel控件
  12. python图片中文字识别
  13. 国内外常用的MD5在线解密网站
  14. 安装完固态硬盘后计算机里没显示,如何解决安装固态硬盘后系统看不到的问题[详细介绍]...
  15. 如何关闭服务器系统防火墙设置方法,怎么关闭防火墙 Windows自带防火墙关闭方法...
  16. STM32关于“NVIC_InitStructure.NVIC_IRQChannel = TIM1_IRQn; error:useof undeclared identifi ‘T1M1_IRQN‘
  17. v4l2接口解析和摄像头数据采集
  18. YOLOv7训练自己的数据集(超详细)
  19. PCB封装欣赏了解之旅(下篇)—— 常用集成电路
  20. 一看就会的奇偶分频电路

热门文章

  1. cef异常处理_cef2623程序在xp下无法启动 出现c06d007f异常的解决方法
  2. iview学习帮助文档
  3. 三国志战略版:SP吕蒙携手都督重出江湖
  4. 根据ParentId生成树状结构这po事
  5. 很经典的十五句话,从别人的blog上看来的!
  6. iOS 文字动画,文字逐个显示
  7. Firefox 地址栏用法三: 搜索引擎
  8. windows配置DNS
  9. 网站域名服务器加密,网站域名利用https防劫持方法
  10. Python 打字小游戏开发,来体验不一样的打字游戏乐趣(完结篇)