안녕하세요 제 코드에 반례가 있을까요?
364
권성민
작성한 질문수 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
2-T 질문
0
6
0
코딩 살구클럽 가입 문의
0
67
2
코딩살구클럽 가입문의
0
69
2
3-K private case 질문
0
66
2
안녕하세요. 코딩살구클럽 문의드립니다!
0
78
2
7:41 듣다가 질문합니다
0
77
2
코드 리뷰 요청드립니다!
0
83
2
코딩살구클럽 계정 문의
0
79
2
SK하이닉스 대비 강의수강
0
217
3
코딩살구클럽 등록부탁드립니다.
0
78
2
7-F 재귀로 풀시 런타임애러
0
75
1
1-N 문제 질문입니다. (+ 채점오류)
0
82
2
코딩살구클럽 가입 확인 부탁드립니다.
0
86
2
직장인 코테 합격 공부방법 문의
0
127
2
코딩살구클럽 가입 방법
0
96
2
6-H 체점 관련 질문
0
74
1
채점서버 연결 관련 질문입니다
0
101
2
삼성 s직군
0
88
1
삼성 코테 없어짐
0
213
1
코딩살구클럽 가입부탁드립니다
0
87
2
코딩살구클럽 가입 요청 확인부탁드립니다
0
69
2
5-S 테스트 케이스 질문
0
78
2
코살 문제풀이 환경
0
88
2
2 - T 오큰수 문제가 있는 것 같습니다.
0
82
1





