UVALive 5886 The Grille (模拟,数组旋转)

UVALive 5886 The Grille


题意:解码,输入板子一块,字母table一块 有hOle的就读取,然后顺时旋转90度


简单题,就是旋转本来想麻烦了,但是我有两个好队友......

水题一枚  注意输入输出+旋转即可

不过如果把板子全部扫描就TLE了,于是存O点



#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[1005][1005];

struct hole
{
    int x,y;

}h[1000005];


void roll_90(hole &a,int n)
{
    int x=a.y,y=n-a.x-1;
    a.x=x;
    a.y=y;
}

bool cmp(hole a,hole b)
{
    if(a.x<b.x)
        return 1;
    else if(a.x==b.x)
        if(a.y<b.y)
            return 1;
    return 0;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("h.in","r",stdin);
    #endif // ONLINE_JUDGE

    int n;
    while(~scanf("%d",&n)&&n)
    {
        getchar();
        char tmp;
        int cnt=0;

        for(int _=0;_<n;_++)
        {
            for(int __=0;__<n;__++)
            {
                scanf("%c",&tmp);
                if(tmp=='O') h[cnt].x=_,h[cnt++].y=__;
                //printf("%c",tmp);
            }
            //puts("");
            getchar();
        }


        for(int _=0;_<n;_++)
        {
            for(int __=0;__<n;__++)
                scanf("%c",&s[_][__]);
            //puts(s[_]);
            getchar();
        }

        for(int _=0;_<4;_++)
        {
            sort(h,h+cnt,cmp);
            for(int __=0;__<cnt;__++)
            {
                //printf("\n%d,%d\n",h[__].x,h[__].y);
                printf("%c",s[h[__].x][h[__].y]);
                roll_90(h[__],n);
            }
        }
        puts("");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值