안녕하세요 제 코드에 반례가 있을까요?
345
권성민
작성한 질문수 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
5-B
0
16
2
4 - A
0
33
2
코딩살구클럽 입장이 안됩니다
0
82
2
4-F 경우의 수 질문입니다.
0
35
2
코딩살구클럽 가입이 안됩니다.
0
85
2
살구 클럽에 대한 질문있습ㄴ디ㅏ
0
63
1
교안 158페이지 문의드립니다
0
46
2
코딩살구클럽 관련 건의사항
0
119
1
코살에 19942 다이어트 문제에 N의 범위가 빠져있슴니다
0
45
1
진행 방법 질문드립니다!
0
83
2
2-I) 왜 이 문제가 그래프이론 카테고리에 있는지 잘 모르겠습니다.
0
64
2
2주차 개념#12 트리 순회
0
33
2
백준사이트가 종료된다고 합니다.
0
318
2
백준 서비스 종료
9
953
1
sk 하이닉스 코테 대비
0
388
2
3-G 최댓값 질문
0
54
1
모듈러 연산 값이 10이 아닌 경우도 있지 않나요?
0
84
2
3-I 코드 질문드립니다.
0
66
2
3-N 질문 있습니다.
0
68
2
학습방법
0
105
2
4-H 질문 있습니다 (코드 리뷰)
0
69
2
코딩테스트 어디까지 준비해야 하는지 질문이 있습니다.
0
186
2
2-O 반례가 무엇일지 어떤 부분이 틀렸는지 잘 모르겠습니다.
0
74
2
2주차 개념 #4-2. 인접행렬 질문있습니다.
0
66
2





