개발자 톡

연습문제 톡 [21년 재직자 대회 예선] 전광판

반례나 틀린부분 좀 찾아주세요 아무리 해도 모르겠어요..

등록일
2024-03-22 14:13:44
조회수
227
작성자
rlacksrl00

import java.io.*;

import java.util.*;


public class Main {


  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int T = Integer.parseInt(br.readLine());

    int[][] cases = {{0, 4, 3, 2, 4, 3, 2, 2, 1, 2},

        {4, 0, 5, 3, 2, 5, 6, 2, 5, 4},

        {3, 5, 0, 3, 5, 4, 3, 5, 2, 3},

        {2, 3, 3, 0, 3, 2, 3, 3, 2, 1},

        {4, 2, 5, 3, 0, 3, 4, 2, 3, 2},

        {3, 5, 4, 2, 3, 0 ,1, 3, 2, 1},

        {2, 6, 3, 3, 4, 1, 0, 4, 1, 2},

        {2, 2, 5, 3, 2, 3, 4, 0, 3, 2},

        {1, 5, 2, 2, 3, 2, 1, 3, 0, 1},

        {2, 4, 3, 1, 2, 1, 2, 2, 1, 0}};

    int[] caseX = {6, 2, 5, 5, 4, 5, 6, 4, 7, 6};


    for (int t=0; t<T; ++t) {

      int[] src = new int[5];

      int[] dst = new int[5];

      for (int i=0; i<5; ++i) {

        src[i] = -1;

        dst[i] = -1;

      }


      StringTokenizer st = new StringTokenizer(br.readLine());


      int srcValue = Integer.parseInt(st.nextToken());

      int dstValue = Integer.parseInt(st.nextToken());

      int srcIdx = 4;

      int dstIdx = 4;


      while (srcValue > 0) {

        src[srcIdx] = srcValue % 10;

        srcValue /= 10;

        --srcIdx;

      }


      while (dstValue > 0) {

        dst[dstIdx] = dstValue % 10;

        dstValue /= 10;

        --dstIdx;

      }


      int result = 0;

      for (int i=0; i<5; ++i) {

        if (src[i] == -1) {

          if (dst[i] != -1)

            result += caseX[dst[i]];

        }

        else if (dst[i] == -1) {

            result += caseX[src[i]];

        }

        else {

          result += cases[src[i]][dst[i]];

        }

      }


      System.out.println(result);

    }

  }

}


도저히 찾아보려고 해도 틀린 부분이나 반례를 못 찾겠는데 자꾸 틀렸다고 뜨네요ㅜㅜ

#[21년_재직자_대회_예선]_전광판

이 카테고리의 톡 더보기