旋转过程的下标变化,画个2x2的表格,模拟就可以出来了

#include <string>
#include<iostream>
#include<map>
#include<memory.h>
#include<vector>
#include<algorithm> namespace cc
{
using std::cout;
using std::endl;
using std::cin;
using std::map;
using std::vector;
using std::string;
using std::sort; constexpr int N = 51; map<string, int> status;
int board[N][N]; int n;
string toString(int b[][N])
{
string str = "";
for (int i=1;i<=n;i++)
{
for (int j=1;j<=n;j++)
{
str += std::to_string(b[i][j]);
}
}
return str; } string xuanzhuan(int i)
{
int temp[N][N];
if (i == 0)
{
//顺时针90度
for (int i = 1, k = n; i <= n; i++, k--)
for (int j = 1; j <= n; j++)
temp[j][k] = board[i][j];
return toString(temp);
}
else if (i==1)
{
for (int i = 1, k = n; i <= n; i++, k--)
for (int j = 1; j <= n; j++)
temp[j][k] = board[i][j];
// 180
int temp2[N][N];
for (int i = 1, k = n; i <= n; i++, k--)
for (int j = 1; j <= n; j++)
temp2[j][k] = temp[i][j];
return toString(temp2);
}
else if (i==2)
{ for (int i = 1; i <= n; i++)//逆时针90度
for (int j = 1, k = n; j <= n; j++, k--)
temp[k][i] = board[i][j];
return toString(temp);
} } void solve()
{
while (cin>>n&&n)
{
memset(board,0,sizeof(board));
status.clear();
int r, c;
char op;
int ok = 0;
int play = 1;
int step = 0;
for (int i=1;i<=2*n;i++)
{
cin >> r >> c >> op;
if (op=='-')
{
//nazou
board[r][c] = 0;
}
else
{
board[r][c] = 1;
}
if(ok==0)
{
step=i;
play = i;
string str = "";
str = xuanzhuan(0);
if (ok==0&&status[str] == 1)
{
ok = 1;
}
str = xuanzhuan(1);
if (ok == 0 && status[str] == 1)
{
ok = 1;
}
str = xuanzhuan(2);
if (ok == 0 && status[str] == 1)
{
ok = 1;
}
str = toString(board);
if (ok == 0 && status[str] == 1)
{
ok = 1;
}
status[str] = 1;
}
}
if (ok == 0)
{
cout << "Draw" << endl;
}
else
{
cout << "Player " << (play % 2+1) << " wins on move " << step << endl;
}
}
} }; int main()
{ #ifndef ONLINE_JUDGE
freopen("d://1.text", "r", stdin);
#endif // !ONLINE_JUDGE
cc::solve(); return 0;
}

  

uva-141-枚举的更多相关文章

  1. UVa 12169 (枚举+扩展欧几里得) Disgruntled Judge

    题意: 给出四个数T, a, b, x1,按公式生成序列 xi = (a*xi-1 + b) % 10001 (2 ≤ i ≤ 2T) 给出T和奇数项xi,输出偶数项xi 分析: 最简单的办法就是直接 ...

  2. UVa 140 (枚举排列) Bandwidth

    题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. ...

  3. UVa 1151 (枚举 + MST) Buy or Build

    题意: 平面上有n个点,现在要把它们全部连通起来.现在有q个套餐,如果购买了第i个套餐,则这个套餐中的点全部连通起来.也可以自己单独地建一条边,费用为两点欧几里得距离的平方.求使所有点连通的最小费用. ...

  4. Even Parity UVA - 11464 (枚举)

    从来没有觉得枚举有多费脑子的.但是这道题还是很香的. 思路:就是非常简单的枚举啦.   从一般的枚举开始考虑.一般的做法就是在所有的格子中有两种状态1, 0. 而一共有225个格子,所有一共要枚举的情 ...

  5. UVa 1354 枚举子集 Mobile Computing

    只要枚举左右两个子天平砝码的集合,我们就能算出左右两个悬挂点到根悬挂点的距离. 但是题中要求找尽量宽的天平但是不能超过房间的宽度,想不到要怎样记录结果. 参考别人代码,用了一个结构体的vector,保 ...

  6. UVA 141 The Spot Game 斑点游戏。。

     The Spot Game  The game of Spot is played on an NxN board as shown below for N = 4. During the game ...

  7. Uva 11754(枚举+中国剩余定理)

    #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inclu ...

  8. 【原创】项目三Raven-2

    实战流程 1,C段扫描,并发现目标ip是192.168.186.141 nmap -sP 192.168.186.0/24 扫描目标主机全端口 nmap -p- 192.168.186.141 访问8 ...

  9. 10年省赛-Greatest Number (二分+暴力) + 12年省赛-Pick apples(DP) + UVA 12325(暴力-2次枚举)

    题意:给你n个数,在里面取4个数,可以重复取数,使和不超过M,求能得到的最大的数是多少: 思路:比赛时,和之前的一个题目很像,一直以为是体积为4(最多选择四次)的完全背包,结果并不是,两两求和,然后二 ...

  10. UVa 10465 Homer Simpson (枚举)

    10465 - Homer Simpson Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

随机推荐

  1. 字符串CRC校验

    字符串CRC校验 <pre name="code" class="python"><span style="font-family: ...

  2. 《JavaScript设计模式与开发》笔记 7.单例模式

    废话一箩筐就这个原来 var instance; return function asdf(name){ if(!this.instance){ this.instance = new asdf(na ...

  3. 美剧黑名单的插曲《Jolene》

    网易上有Slowdown 版本.<Jolene>Dolly Parton

  4. SynergyS7G2RTC时钟模块的使用

    RTC功能描述 RTC时钟模块是Synergy芯片的一个时间外设,主要用于日期时间的存储和控制,有别于一般MCU中的Timer,RTC时钟有两种计时模式,日期模式和二进制计时模式,其中日期模式的时间可 ...

  5. 查询某个SPID,session_id对应的执行sql.

    select er.session_id, CAST(csql.text AS varchar(255)) AS CallingSQL from master.sys.dm_exec_requests ...

  6. java中的强,软,弱,虚引用

    引用的应用场景 我们都知道垃圾回收器会回收符合回收条件的对象的内存,但并不是所有的程序员都知道回收条件取决于指向该对象的引用类型.这正是Java中弱引用和软引用的主要区别. 如果一个对象只有弱引用指向 ...

  7. 【Java】线程转储分析 ThreadDump

    [[TOC]] 通过分析 ThreadDump 来查询Java程序运行情况 获取线程转储文件 有多种方式可以获取转储文件,可参考链接HOW TO TAKE THREAD DUMPS? – 8 OPTI ...

  8. Ubuntu 14.10 下Hadoop HttpFS 配置

    因为hadoop集群中需要配置一个图形化管理数据的截面,后来找到HUE,那么在配置HUE的过程中,发现需要配置httpfs,因为配置了httpfs,hue才能去操作hdfs中的数据. HttpFs能干 ...

  9. C/C++程序CPU问题分析

    转载地址:http://www.10tiao.com/html/473/201606/2651473094/1.html   程序的CPU问题是另外一类典型的程序性能问题,很多开发人员都受到过程序CP ...

  10. Hadoop是怎么分块Block的?

    不多说,直接上干货! hadoop的分块有两部分. 第一部分就是数据的划分(即把File划分成Block),这个是物理上真真实实的进行了划分,数据文件上传到HDFS里的时候,需要划分成一块一块,每块的 ...