Manipulating the Power Square hdu2598(居然是题目看错了)
来源:互联网 发布:女生男友力max知乎 编辑:程序博客网 时间:2024/04/29 06:46
/*
终于AC了,看来我读题的能力还是很欠缺啊!!
The command ”MOVE” is followed by one more more moves:
If move attempts to swap 0 with a non-existent neighbor, then output ”FAILED” on a single line
and stop attempting the remaining moves.
题目没有读懂就做题目是致命的错误啊
(
MOVE right up 比如不能right可以up 那么得到的
还是原来的 up没变(就是failed就break掉了)
)
谢文策大人给我分析了,我才明白的我题目读错了,好纠结
这次的比赛让我受益匪浅!
我读题的能力是完全欠缺的,代码的水平应付一些水题简单的算法题应该没有问题的
可是为何比赛的时候总是那么不理想呢?想想原因吧
*/
#include<iostream>//2460100 2010-05-16 10:57:25 Accepted 2598 0MS 324K 2865 B C++ 悔惜晟
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
//int dir[4][2] = {{-1 ,0}, {0, -1}, {0, 1}, {1 , 0}};
int main()
{
int n, i, j;
char str[2000];
int map[105][105];
int map1[105][105];
int x0, y0;
int x1, y1;
int num;
int len ;
//while(scanf("%d", &n) != EOF)
//while(1)
///while(scanf("%s", str) != EOF)
while(gets(str))
{
// memset(map, 0, sizeof(map));
// scanf("%d", &n);
// getchar();
if(str[0] >= '0' && str[0] <= '9')
{
n = 0;
len = strlen(str);
for(i = 0; i < len; i++)
{
n = 10 * n + str[i] - '0';
}
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
{
scanf("%d", &map[i][j]);
if(map[i][j] == 0)
{
x0 = i;
y0 = j;
}
map1[i][j] = map[i][j];
}
getchar();
continue;
}
else if(strcmp(str, "SHOW") == 0)
{
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
{
if(j == n - 1)
printf("%d", map[i][j]);
else
printf("%d ", map[i][j]);
}
printf("/n");
}
printf("/n");
continue;
}
else
{
//memset(str1, 0, sizeof(str1));
len = strlen(str);
for(i = 5; i < len;)
{
if(str[i] == 'u')
{
x1 = x0 - 1;
y1 = y0;
if(x1 < 0)
{
printf("FAILED/n");
break;
}
num = map1[x0][y0];
map1[x0][y0] = map1[x1][y1];
map1[x1][y1] = num;
x0 = x1;
y0 = y1;
i += 3;
//printf("MOVED/n");
}
else if(str[i] == 'l')
{
x1 = x0;
y1 = y0 - 1;
if(y1 < 0)
{
printf("FAILED/n");
break;
}
num = map1[x0][y0];
map1[x0][y0] = map1[x1][y1];
map1[x1][y1] = num;
x0 = x1;
y0 = y1;
i += 5;
//printf("MOVED/n");
}
else if(str[i] == 'r')
{
x1 = x0;
y1 = y0 + 1;
if(y1 >= n)
{
printf("FAILED/n");
break;
}
num = map1[x0][y0];
map1[x0][y0] = map1[x1][y1];
map1[x1][y1] = num;
x0 = x1;
y0 = y1;
i += 6;
//printf("MOVED/n");
}
else
{
x1 = x0 + 1;
y1 = y0;
if(x1 >= n)
{
printf("FAILED/n");
break;
}
num = map1[x0][y0];
map1[x0][y0] = map1[x1][y1];
map1[x1][y1] = num;
x0 = x1;
y0 = y1;
i += 5;
//printf("MOVED/n");
}
}
if(i > len)
{
printf("MOVED/n");
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
map[i][j] = map1[i][j];
}
}
}
}
- Manipulating the Power Square hdu2598(居然是题目看错了)
- hdu 2598 Manipulating the Power Square 模拟水题
- 杯勒个具 ~~题目看错了
- 你会不会是“看错了”?
- 2 Manipulating the Pixels
- 这是一道简单题目,我居然这个都搞错误了,easy,这个可以直接上公式
- 【杭电】2016 数据的交换输出 正确版(之前题目看错了)
- ZOJ 3647 Gao the Grid(居然是暴力)
- 她摸过,看了号码,居然是他!
- EVE 居然是用 python 写的!!太不可思议了
- 大神帮我看看错了吗??
- Demonstration: Manipulating the Clipboard in Delphi
- OpenCV2 && Qt4 chapter2: Manipulating the Pixels
- Manipulating the positions of desktop icons
- 今天居然是黑色星期五
- 居然是BUG~!
- 题目:Maximal Square
- 送两套外贸童装不仅避免了裁员的风险,出乎预料的是居然还升职了
- LockableDataGrid可锁定列的DataGrid
- Linux 启动详解
- seo之整站优化
- squid
- poj 最小生成树1258
- Manipulating the Power Square hdu2598(居然是题目看错了)
- WAMP5环境配置
- 基于实时定位技术的分布式照明监控系统
- 批量更改文件名,查找替换文件字符串
- 一致性hash算法 - consistent hashing
- mysql 时间函数
- 舆情分析与影响的经验记录一
- Javascript弹出对话框3种方式
- 什么是WebSphere Application Server Network Deployment