zoukankan      html  css  js  c++  java
  • Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力

    Problem F. Turning Grille

    题目连接:

    http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c7022&all_runs=1&action=140

    Description

    ‘Turning grille’ method is one of the simplest forms of transposition cipher. A variant of this method is
    as follows. The sender of the message writes it onto a square sheet of paper gridded into N rows and
    N columns, one character per cell. The number N is even. A grille is used for ciphering—a pierced sheet
    of cardboard of the same size as the paper. There are N2/4 holes made in the grille, and one cell can be
    seen through each hole. When writing a message, the grille is placed on a sheet of paper, and the letters
    of the message are written into the holes from top to bottom. After all holes have been filled, the grille
    is turned 90◦
    clockwise, and the writing goes on. The grille can be turned three times, and the message
    length does not exceed N2
    .
    The receiver of the message has the same grille and, performing the same manipulations, reads the
    characters that appear in the holes.
    A well-formed grille must not show the same paper sheet cell several times during grille rotations. However,
    the holes are manufactured by hand and a master can make mistakes, especially when creating a big
    grille. . .
    Write a program that checks if a grille is correct.

    Input

    The first line of input contains the integer N, the size of the paper (4 ≤ N ≤ 1000, N is even). N lines
    follow, each corresponds to a row of the grille and contains N characters . (no hole) or * (a hole). The
    number of holes is N2/4.

    Output

    Output the line YES or NO depending on whether the grille is well-formed or not.

    Sample Input

    4
    ...
    ..
    *
    ....
    .*..

    Sample Output

    YES

    Hint

    题意

    给你一个解密卡,就是那个*就是洞洞,然后转90°,转四次,问你洞洞能不能覆盖所有点。

    保证解密卡有n^2/4个洞洞。

    题解:

    哈哈,我说这个就是像小时候玩过的冒险小虎队的那个解密卡。

    这个xjb搞一搞就好了

    代码

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 1e3 + 15;
    int N ;
    char str[4][maxn][maxn];
    
    int main(int argc, char * argv[]){
       // freopen("in.txt","r",stdin);
        scanf("%d",&N);
        for(int i = 0 ; i < N ; ++ i){
            scanf("%s" , str[0][i]);
        }
        for(int i = 1 ; i < 4 ; ++ i) for(int j = 0 ; j < N ; ++ j) for(int k = 0 ; k < N ; ++ k) str[i][j][k] = str[i - 1][k][N-j-1];
       /* for(int i = 0 ; i < 4 ; ++ i){
            for(int j = 0 ; j < N ; ++ j) cout << str[i][j] << endl;
            cout << endl;
        }*/
        vector < pair < int , int > > vi;
        for(int i = 0 ; i < 4 ; ++ i)
            for(int j = 0 ; j < N ; ++ j)
                for(int k = 0 ; k < N ; ++ k)
                    if( str[i][j][k] == '*' )
                        vi.push_back( make_pair( j ,  k ) );
        sort( vi.begin() , vi.end() );
        assert( vi.size() == N * N );
        int C = unique( vi.begin() , vi.end() ) - vi.begin();
        if( C == N * N ) printf("YES
    ");
        else printf("NO
    ");
        return 0;
    }
  • 相关阅读:
    xshell5连接虚拟机的小问题处理
    centos下安装python的过程
    windows下安装配置redis
    Mysql 插入修改报Incorrect string value: 'xE7xACxAC' for column 'DetectionResult' at row 1错误
    MD5 以key和iv保存 FormsAuthentication.HashPasswordForStoringInConfigFile过时的问题
    The user specified as a definer ('root'@'%') does not exist的解决方法
    C#判断字符串中包含某个字符的个数
    jquery easyui datagrid 在翻页以后仍能记录被选中的行及刷新设置选中行数据
    bat批处理删除多少天前的文件
    C# 获取系统字体方法
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5767067.html
Copyright © 2011-2022 走看看