안녕하세요 제 코드에 반례가 있을까요?
355
권성민
작성한 질문수 2
0
문제를 풀어서 보여지는 테스트 케이스는 다 맞는데 반례가 있을까요?
#include <bits/stdc++.h>
using namespace std;
int n;
int temp;
pair<int, int> team1;
pair<int, int> team2;
int team1total;
int team2total;
string mmss;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for(int i = 0; i < n; i++){
cin >> temp >> mmss;
string m = mmss.substr(0,2);
string s = mmss.substr(3,2);
int mm = atoi(m.c_str());
int ss = atoi(s.c_str()) + 60*mm;
if(team1.first == team2.first){
if(temp == 1){
team1.first++;
team1.second = ss;
}else{
team2.first++;
team2.second = ss;
}
}else if(team1.first > team2.first){
if(temp == 1){
team1.first++;
}else{
team2.first++;
if(team1.first == team2.first){
team1total += ss - team1.second;
team1.second = 0;
team2.second = 0;
}
}
}else if(team1.first < team2.first){
if(temp == 2){
team2.first++;
}else{
team2.first++;
if(team1.first == team2.first){
team2total += ss - team2.second;
team2.second = 0;
team1.second = 0;
}
}
}
}
if(team1.second != 0){
team1total += 48*60 - team1.second;
}else if(team2.second != 0){
team2total += 48*60 - team2.second;
}
string total1Time_first = to_string(team1total / 60);
string total1Time_second = to_string(team1total % 60);
string total2Time_first = to_string(team2total / 60);
string total2Time_second = to_string(team2total % 60);
if(total1Time_first.length() == 1)total1Time_first = "0" + total1Time_first;
if(total1Time_second.length() == 1)total1Time_second = total1Time_second +"0";
if(total2Time_first.length() == 1)total2Time_first = "0" + total1Time_first;
if(total2Time_second.length() == 1)total2Time_second = total2Time_second +"0";
cout << total1Time_first+":"+total1Time_second << "\n";
cout << total2Time_first+":"+total2Time_second << "\n";
return 0;
}
답변 1
6-H 체점 관련 질문
0
8
0
채점서버 연결 관련 질문입니다
0
31
1
삼성 s직군
0
33
0
삼성 코테 없어짐
0
81
1
코딩살구클럽 가입부탁드립니다
0
40
2
코딩살구클럽 가입 요청 확인부탁드립니다
0
35
2
5-S 테스트 케이스 질문
0
37
2
코살 문제풀이 환경
0
54
2
2 - T 오큰수 문제가 있는 것 같습니다.
0
46
1
추천 추가문제들
0
44
2
프로그래머스 코테 환경 관련해서 질문드립니다.
0
50
2
해당 문제에 대한 채점이 코딩살구클럽에서 올바르게 처리되지 않습니다.
0
44
2
균형 이진 트리 설명 시 높이 숫자
0
33
2
4-H 질문드립니다.
0
37
2
1-K 질문드립니다.
0
43
2
대기업 인적성 시험 질문
0
43
2
4-C 질문드립니다
0
43
2
[수학숙제 / BOJ 2870] 채점 서버 오작동
0
40
1
코테 준비 질문
0
58
1
살구클럽가입 요청드려요
0
42
2
1-I 문제 질문
0
46
2
코딩살구클럽 가입
0
61
2
AI 코딩 도구 사용 시 학습 방법 조언
0
56
2
코딩살구클럽 오류
0
67
2





