【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

旋转和翻转,会发现。
如果可以顺着某个方向一直放的话。
总是能转换成往下或者往右连的。
则只要能够出现一个连接顺序的循环,则总是有解的。
->转化成图论模型
如果一个正方形有A+
另外一个正方形有A-B+C+D-
那么从A+连3条边分别到B+,C+,D-
按照这样的方式连,如果能出现一个环的话,肯定是有解的
->有一条边,就已经说明能够新增加一个正方形了。

拓扑排序判环即可

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
*/
#include <bits/stdc++.h>
using namespace std; const int N = 52;
const int NN = (int) 4e4; int n,tot;
map <string,int> mmap;
int g[N+10][N+10],du[N+10],num;
bool bo[N+10];
vector <int> v[NN+100];
queue <int> dl; int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0); for (char i = 'A';i <= 'Z';i++){
string temp ="";
temp+= i;temp += '-';
mmap[temp] = ++tot;
} for (char i = 'A';i <= 'Z';i++){
string temp = "";
temp += i;temp += '+';
mmap[temp] = ++tot;
} for (int i = 1;i <= NN;i++) v[i].resize(4); while ( cin >> n ){
memset(g,0,sizeof g);
memset(du,0,sizeof du);
memset(bo,0,sizeof bo);
for (int ii = 1;ii <= n;ii++){
string s;
cin >> s;
string temp = "";
for (int i = 0,j = 0;i < 7;i+=2,j++){
temp = s.substr(i,2);
v[ii][j] = mmap[temp];
bo[v[ii][j]] = 1;
}
} for (int ii = 1;ii <= n;ii++){
for (int i = 0;i < 4;i++){
if (v[ii][i]==0) continue;
int x = (v[ii][i]>26)?(v[ii][i]-26):(v[ii][i]+26);
if (!bo[x]) continue; for (int j = 0;j <4 ;j++)
if (i!=j){
int y = v[ii][j];
if (y==0) continue;
if (!g[x][y]){
du[y]++;
}
g[x][y] = 1;
}
}
} num = 52;
for (int i = 1;i <= 52;i++)
if (du[i]==0){
dl.push(i);
du[i] = -1;
} while (!dl.empty()){
num--;
int x = dl.front();
dl.pop();
for (int i = 1;i <= 52;i++)
if (g[x][i]){
g[x][i] = g[i][x] = 0;
du[i]--;
if (du[i] == 0){
dl.push(i);
}
}
} if (num!=0){
cout << "unbounded" << endl;
}else{
cout << "bounded" << endl;
}
}
return 0;
}

最新文章

  1. 一个大数据的demo
  2. HTML5的学习--performance获取加载时间的工具
  3. Cordova - 使用Cordova开发iOS应用实战1(配置、开发第一个应用)
  4. [Android Tips] 1. Getting StatusBar Height
  5. Android手势锁实现
  6. Asp.net中用户自定义控件 ascx的使用
  7. [数据结构]Treap简介
  8. Python学习之一:Python2.7与opencv2.4安装配置
  9. dotnet core 开发无缝兼容Http和Websocket协议的接口服务
  10. python NLTK安装
  11. VNF网络性能提升解决方案及实践
  12. ubuntu上编译linux内核
  13. Viewer.js 是一款强大的 jQuery 图像浏览插件。
  14. &lt;转&gt;特征工程(一)
  15. AppScan安全测试入门操作
  16. WebLogic Server 12c相对JBoss EAP 6的优势
  17. javascript - = 、==、===、!=、!==、&amp;&amp;、||、!
  18. 设置 PyCharm 软件中 Terminal 窗口 中启动的 python 交互命令的版本
  19. windows下启动Apache报443错误!
  20. [NOIP模拟赛][贪心]奶牛晒衣服.

热门文章

  1. swift 创建第一个UIAlertView 和UIActionSheet
  2. jquery06 jQuery.extend 给jQuery函数添加、继承 静态方法
  3. modSecurity规则学习(五)——DDOS攻击检测
  4. ctags 寻找方法定义处
  5. 49.大量qq号及qq密码挖掘到结构体并实现精确分配内存以及快速排序
  6. iOS -读书笔记-网络请求
  7. hdu 3294 Girls&amp;#39; research
  8. CSS3:元素的边框、背景和大小
  9. inflater-布局转化实现
  10. php全局变量的使用