zoukankan      html  css  js  c++  java
  • CodeForces Gym 100935C OCR (水

    OCR
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
     

    Description

    standard input/output
    Statements

    Optical Character Recognition (OCR) is one of the most famous fields of Artificial Intelligence. The main purpose of OCR is to recognize printed text (or handwriting) and convert it to the machine encoded-text. You may have seen similar applications in your smartphone: you use your camera to take a photo that contains text, then, the text is translated or saved in PDF, for example. In this problem we deal with a very limited case of OCR. You have a scanned character which is either ‘0’ (number zero) or ‘8’ (number eight) and you have to decide what number it is. The input will be an image that contains exactly one character (It is guaranteed that this character is either ‘0’ or ‘8’). The image has 2 colors: white (represented with dot ‘.’) and black (represented with asterisk ‘*’). For simplicity, the borders of the image are always white. It’s also guaranteed that black lines inside the image are either vertical or horizontal. So you may safely assume that the shapes of ‘0’ and ‘8’ inside the image are the same as their shapes in digital clocks. However, they might be stretched or not positioned in the center of the image.

    Input

    The first line will be the number of test cases T (T<100). Each test case starts with two positive integers (n,m) denoting the dimensions of the image. (n,m < 20). Each of the following n lines contains m values which represent the image.

    Output

    For each test case, print one line which contains the number of the test case, and the recognition result: ‘Zero’ or ‘Eight’. See the samples and follow the output format.

    Sample Input

    Input
    3
    8 10
    ..........
    ..*****...
    ..*...*...
    ..*...*...
    ..*****...
    ..*...*...
    ..*****...
    ..........
    6 10
    ..........
    ..*****...
    ..*...*...
    ..*...*...
    ..*****...
    ..........
    10 7
    .......
    .......
    .......
    .......
    ..****.
    ..*..*.
    ..****.
    ..*..*.
    ..****.
    .......
    Output
    Case 1: Eight
    Case 2: Zero
    Case 3: Eight



    看上去很高端的题 其实很水
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <iomanip>
    #include <math.h>
    #include <map>
    using namespace std;
    #define FIN     freopen("input.txt","r",stdin);
    #define FOUT    freopen("output.txt","w",stdout);
    #define INF     0x3f3f3f3f
    #define lson    l,m,rt<<1
    #define rson    m+1,r,rt<<1|1
    typedef long long LL;
    
    const int MAXN=1000+5;
    char Map[25][25];
    int flag;
    
    int llss(int x,int y){
        if(Map[x][y+1]=='*')  {flag++;}
        if(Map[x][y]=='.')  return 0;
        llss(x+1,y);
    }
    
    
    int main()
    {
        //FIN
        int T;
        scanf("%d",&T);
        for(int z=1;z<=T;z++){
            int n,m;
            scanf("%d%d",&n,&m);
            for(int i=1;i<=n;i++)
                for(int j=1;j<=m;j++){
                    //scanf("%c",Map[i][j]);
                    cin>>Map[i][j];
                }
    
            flag=0;
            int k=0;
            for(int i=1;i<=n;i++){
                for(int j=1;j<=m;j++){
                    if(Map[i][j]=='*'){
                        llss(i,j);
                        k=1;
                        break;
                    }
                }
                if(k==1)  break;
            }
    
            if(flag==2)  printf("Case %d: Zero
    ",z);
            if(flag==3)  printf("Case %d: Eight
    ",z);
        }
    }
    

      

  • 相关阅读:
    C语言结构体中的函数指针与函数
    写博客
    图灵C/C++图书阅读路线图
    c语言预处理
    Gnu gprof
    linux下全目录全文搜索强大工具grep
    openssl源代码结构
    js学习笔记——脚本化浏览器窗口
    js学习笔记——js的功能限制
    js学习笔记——在html中嵌入脚本
  • 原文地址:https://www.cnblogs.com/Hyouka/p/5754818.html
Copyright © 2011-2022 走看看