2016년 4월 5일 화요일

2082 - 시계

https://www.acmicpc.net/problem/2082

0~9까지 표현되는 샘플을 만들고, 시계에는 불이 켜져있는 데 샘플은 꺼져있다면 그 숫자는 대상에서 제외한다. (시계에서 꺼져있는건 무시해도 된다)

시계가 뒤집어져있다거나 잘못된 시간(ex. 28:00) 등의 입력은 없는 것 같다.


#include <bits/stdc++.h>
using namespace std;

char digit[10][17]={
    "####.##.##.####",
    "..#..#..#..#..#",
    "###..#####..###",
    "###..####..####",
    "#.##.####..#..#",
    "####..###..####",
    "####..####.####",
    "###..#..#..#..#",
    "####.#####.####",
    "####.####..####"
};

vector<int> cand[4];
char input[5][17];

bool match(int x, int k){
    for(int i=0; i<5; ++i){
        for(int j=0; j<3; ++j){
            if(input[i][x+j] == '#' && digit[k][i*3+j] == '.') return false;
        }
    }
    return true;
}

int main(){
    for(int i=0; i<5; ++i) gets(input[i]);
    int timer[4]={2, 9, 5, 9};
    for(int x=0; x<4; ++x){
        for(int k=0; k<=timer[x]; ++k){
            if(match(4*x, k)){
                printf("%d", k);
                break;
            }
        }
        if(x==1) putchar(':');
    }
    
    return 0;
}

댓글 없음:

게시글 목록