강의로 돌아가기
impr

6번 테스트케이스 반례가 있을까요?

게시판에 있는 모든 반례를 대입해도 통과하는데, 6번 케이스만 실패하네요.. 반례가 있을까요?

작성중인 코드―Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class Solution {
    public String solution(String video_len, String pos, String op_start, String op_end, String[] commands) {
        String answer = "";
        int posMin = Integer.parseInt(pos.substring(0,2));
        int posSec = Integer.parseInt(pos.substring(3,5));
        int opStartMin = Integer.parseInt(op_start.substring(0,2));
        int opEndMin = Integer.parseInt(op_end.substring(0,2));
        int opStartSec = Integer.parseInt(op_start.substring(3,5));
        int opEndSec = Integer.parseInt(op_end.substring(3,5));
        int vidLenMin = Integer.parseInt(video_len.substring(0,2));
        int vidLenSec = Integer.parseInt(video_len.substring(3,5));


        for(int i=0; i<commands.length; i++) {
            System.out.println(posMin + " " + posSec);    
            if((posMin>opStartMin && posMin<opEndMin) || (posMin==opEndMin && posSec<=opEndSec && opEndMin>opStartMin) || (posMin==opStartMin && posSec >= opStartSec&& opEndMin>opStartMin) || (opStartMin==opEndMin && posMin == opStartMin && posSec>=opStartSec && posSec<=opEndSec)) {
            posMin = opEndMin;
            posSec = opEndSec;
            }
            System.out.println(posMin + " " + posSec);    
            if(commands[i].equals("prev")) {
                if(posMin==0 && posSec<10) {
                    posMin = 0;
                    posSec = 0;
                } else {
                    if(posSec<10) {
                        posMin--;
                        posSec = 60 - (10 - posSec);
                    } else {
                        posSec-=10;
                    }
                }   
            } else if(commands[i].equals("next")) {
                if((posMin==vidLenMin&&posSec+10>vidLenSec) || (posSec+10>59&&posMin+1>vidLenMin)) {
                    posMin = vidLenMin;
                    posSec = vidLenSec;
                } else {
                    if(posSec>50) {
                        posMin++;
                        posSec = (10 + posSec) - 60;
                    } else {
                        posSec+=10;
                    }
                }  

            } 
            System.out.println(posMin + " " + posSec);    
        }

        if((posMin>opStartMin && posMin<opEndMin) || (posMin==opEndMin && posSec<=opEndSec && opEndMin>opStartMin) || (posMin==opStartMin && posSec >= opStartSec&& opEndMin>opStartMin) || (opStartMin==opEndMin && posMin == opStartMin && posSec>=opStartSec && posSec<=opEndSec)) {
            posMin = opEndMin;
            posSec = opEndSec;
            }

        String strMin;
        String strSec;
        if(posMin<10) {
            strMin = "0" + posMin;
        } else {
            strMin = "" + posMin;
        }

        if(posSec<10) {
            strSec = "0" + posSec;
        } else {
            strSec = "" + posSec;
        }


        answer = strMin + ":" + strSec;

        return answer;
    }
}
1 개의 답변
낙방여우

반례입니다.
입력값 〉 "30:00", "29:55", "01:00", "01:30", ["next"]
기댓값 〉 "30:00"

  • impr

    감사합니다!

    impr―2024.09.26 15:10
  • 서찬규

    감사합니다!!

    서찬규―2024.11.08 19:35
답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다.