为什么一个测试点都没过,样例是对的
查看原帖
为什么一个测试点都没过,样例是对的
925075
luofre楼主2024/3/11 12:07
#include<iostream>
#include<string>
#include<vector>
// #define int long long
using namespace std;
const int N = 1e5+10;
void solve(){
	string s1,s2;
	
	getline(cin,s1);
	getline(cin,s2);

	int hh1 = (s1[0]-'0')*10+s1[1]-'0';
	int mm1 = (s1[3]-'0')*10+s1[4]-'0';
	int ss1 = (s1[6]-'0')*10+s1[7]-'0';

	int hh2 = (s1[9]-'0')*10+s1[10]-'0';
	int mm2 = (s1[12]-'0')*10+s1[13]-'0';
	int ss2 = (s1[15]-'0')*10+s1[16]-'0';

	int hh3 = (s2[0]-'0')*10+s2[1]-'0';
	int mm3 = (s2[3]-'0')*10+s2[4]-'0';
	int ss3 = (s2[6]-'0')*10+s2[7]-'0';

	int hh4 = (s2[9]-'0')*10+s2[10]-'0';
	int mm4 = (s2[12]-'0')*10+s2[13]-'0';
	int ss4 = (s2[15]-'0')*10+s2[16]-'0';

	int d1 = 0, d2 = 0;
	if(s1.length()==22){
		d1 = s1[20]-'0';
	}
	if(s2.length()==22){
		d2 = s2[20]-'0';
	}
	int time1 = ss1+mm1*60+hh1*3600;
	int time2 = ss2+mm2*60+hh2*3600+d1*86400;
	int time3 = ss3+mm3*60+hh3*3600;
	int time4 = ss4+mm4*60+hh4*3600+d2*86400;
	int ans = (time2-time1+time4-time3)/2;
	printf("%02lld:%02lld:%02lld\n",ans/3600,ans%3600/60,ans%60);

}
signed main(){
	int t;
	cin >> t;
	// scanf("%d",&t);
	getchar();
	while(t--){
		solve();
	}
	return 0;
}
2024/3/11 12:07
加载中...