HDU 2414 Chessboard Dance(模拟题,仅此纪念我的堕落)

题目

模拟题也各种wa,我最近真的堕落了,,,,,智商越来越为负数了!!!!!!!!

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char mp[10][10];
int d=-1;//0shang,1xia,2zuo,3you
int x,y;//weizhi
int weizhi(int i,int j)
{
    if(mp[i][j]==‘<‘){x=i,y=j,d=2;return 1;}
    if(mp[i][j]==‘>‘){x=i,y=j,d=3;return 1;}
    if(mp[i][j]==‘^‘){x=i,y=j,d=0;return 1;}
    if(mp[i][j]==‘v‘){x=i,y=j,d=1;return 1;}
    return 0;
}
void fangxiang()
{
    if(d==0)mp[x][y]=‘^‘;
    else if(d==1)mp[x][y]=‘v‘;
    else if(d==2)mp[x][y]=‘<‘;
    else if(d==3)mp[x][y]=‘>‘;
}
void mov(int num)
{
    while(num--)
    {
        char fro=mp[x][y];
        if(d==0)
        {
            for(int i=x-1;i>=0;i--){
            if(mp[i][y]==‘.‘){mp[i][y]=fro;break;}
            else {
                char tmp=mp[i][y];
                mp[i][y]=fro;
                fro=tmp;
                }
            }
            if(x-1>=0)mp[x][y]=‘.‘,x--;
        }
        else if(d==1){

            for(int i=x+1;i<8;i++){
            if(mp[i][y]==‘.‘){mp[i][y]=fro;break;}
            else {
                char tmp=mp[i][y];
                mp[i][y]=fro;
                fro=tmp;
                }
            }
            if(x+1<8)mp[x][y]=‘.‘,x++;
        }
        else if(d==2){

            for(int i=y-1;i>=0;i--){
            if(mp[x][i]==‘.‘){mp[x][i]=fro;break;}
            else {
                char tmp=mp[x][i];
                mp[x][i]=fro;
                fro=tmp;
                }
            }
            if(y-1>=0)mp[x][y]=‘.‘,y--;
        }
        if(d==3){

            for(int i=y+1;i<8;i++){
            if(mp[x][i]==‘.‘){mp[x][i]=fro;break;}
            else {
                char tmp=mp[x][i];
                mp[x][i]=fro;
                fro=tmp;
                }
            }
            if(y+1<8)    mp[x][y]=‘.‘,y++;
        }
    }
}
void turnn(char cc)
{
    if(cc==‘l‘)
    {
        if(d==0)d=2;
        else if(d==1)d=3;
        else if(d==2)d=1;
        else if(d==3)d=0;
    }
    else if(cc==‘r‘)
    {
         if(d==0)d=3;
        else if(d==1)d=2;
        else if(d==2)d=0;
        else if(d==3)d=1;

    }
    else if(cc==‘b‘)
    {
        if(d==0)d=1;
        else if(d==1)d=0;
        else if(d==2)d=3;
        else if(d==3)d=2;
    }
}
int main()
{
    while(scanf("%s",mp[0])!=EOF)
    {

        if(strcmp(mp[0],"--")==0)break;
        for(int i=1;i<8;i++)
        {
            scanf("%s",mp[i]);
        }
        int fl=0;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(weizhi(i,j)){fl=1;break;}
            }
            if(fl)break;
        }

        while(1)
        {
            char p[10];
            int movee;
            scanf("%s",p);
            if(strcmp(p,"#")==0)break;
            if(strcmp(p,"move")==0){
                scanf("%d",&movee);
                mov(movee);
            }
            else {
                scanf("%s",p);
                turnn(p[0]);
                fangxiang();
            }
        }
        for(int i=0;i<8;i++)
            printf("%s\n",mp[i]);

        printf("\n");
    }
    return 0;
}

时间: 2024-10-23 12:41:53

HDU 2414 Chessboard Dance(模拟题,仅此纪念我的堕落)的相关文章

HDU 2414 Chessboard Dance (强行模拟)

题目链接:HDU 2414 Chessboard Dance 题意:给出一张图,>,<,^,v表示人面对的方向,字母相当于是箱子,箱子可以推出边界,人保证不会做出边界,下面输入指令,按照指令走,输出结束时图的状态: 强行模拟一遍,注意下面给出的案例. >t.p.p.p ...a.... ........ ...bfg.y ...c... ...d.... ...e.... ........ move 3 turn right move 3 turn left move 3 turn le

POJ 3344 &amp; HDU 2414 Chessboard Dance(模拟)

题目链接: PKU:http://poj.org/problem?id=3344 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2414 Description Another boring Friday afternoon, Betty the Beetle thinks how to amuse herself. She goes out of her hiding place to take a walk around the living r

POJ 3344 &amp;amp; HDU 2414 Chessboard Dance(模拟)

题目链接: PKU:http://poj.org/problem? id=3344 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2414 Description Another boring Friday afternoon, Betty the Beetle thinks how to amuse herself. She goes out of her hiding place to take a walk around the living

HDU 4022 Bombing STL 模拟题

手动模拟.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define N 10100 #define inf 1000000010 map<

【HDOJ】2414 Chessboard Dance

简单DFS. 1 /* 2414 */ 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 6 const int n = 8; 7 char map[10][10]; 8 int x, y, d; 9 char dirs[5] = "^v<>"; 10 int dir[4][2] = { 11 -1,0, 1,0, 0,-1, 0,1 12 }; 13 int

HDU 4028 The time of a day STL 模拟题

暴力出奇迹.. #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #include<map> using namespace std; #define ll __int64 #define N 42 ll n,m,ans;

hdu 5641 King&#39;s Phone(暴力模拟题)

Problem Description In a military parade, the King sees lots of new things, including an Andriod Phone. He becomes interested in the pattern lock screen. The pattern interface is a 3×3 square lattice, the three points in the first line are labeled as

HDU 4930 Fighting the Landlords(扯淡模拟题)

Fighting the Landlords 大意: 斗地主....   分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. 给你8种组合:1.

HDU 4925 Apple Tree(模拟题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 解题报告:给你n*m的土地,现在对每一块土地有两种操作,最多只能在每块土地上进行两种操作,第一种是种苹果树操作,第二种是施肥操作,种苹果树操作可以使得该块地 长出一个苹果,施肥操作可以使得与这块土地相邻的土地的苹果产量变为原来的两倍,问可以得到的最多的苹果数量是多少? 例如一个4*4的土地,用1表示在该土地上做第一种操作,0表示在该土地上做第二种操作,可以得到最多苹果的操作如下: 0 1 0