Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define all(c) c.begin(),c.end()
typedef pair<int,int> P;
vector<int> clock[60][60],t;
int main(){
	rep(i,12) rep(j,60) rep(k,60){
		int h[3]={5*i+j/12,j,k},a[3]={0,1,2};
		P p=P(100,100);
		do{
			int x=h[a[0]],y=h[a[1]],z=h[a[2]];
			p=min(p,P((y-x+60)%60,(z-x+60)%60));
		}while(next_permutation(a,a+3));
		clock[p.fs][p.sc].push_back(i*3600+j*60+k);
	}
	while(true){
		int n;
		cin >> n;
		if(n==0) break;
		t.clear();
		P type[10];
		rep(i,n){
			int s[3];
			cin >> s[0] >> s[1] >> s[2];
			P p=P(100,100);
			int a[3]={0,1,2};
			do{
				int x=s[a[0]],y=s[a[1]],z=s[a[2]];
				p=min(p,P((y-x+60)%60,(z-x+60)%60));
			}while(next_permutation(a,a+3));
			type[i]=p;
			rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
		}
		sort(all(t));
		t.erase(unique(all(t)),t.end());
		int len=1e7,ans=-1;
		rep(i,t.size()){
			int mx=0;
			rep(j,n){
				P p=type[j];
				vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
				if(it==clock[p.fs][p.sc].end()){
					mx=1e7;
					break;
				}
				mx=max(mx,*it);
			}
			if(mx==1e7) break;
			if(len>mx-t[i]) len=mx-t[i],ans=t[i];
		}
		printf("%02d:%02d:%02d %02d:%02d:%02d\n",ans/3600,ans%3600/60,ans%60,(ans+len)/3600,(ans+len)%3600/60,(ans+len)%60);
	}
}

Compiler output:
a.cc:11:25: error: 'std::vector<int> clock [60][60]' redeclared as different kind of entity
   11 | vector<int> clock[60][60],t;
      |                         ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:72:16: note: previous declaration 'clock_t clock()'
   72 | extern clock_t clock (void) __THROW;
      |                ^~~~~
a.cc: In function 'int main()':
a.cc:20:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |                 clock[p.fs][p.sc].push_back(i*3600+j*60+k);
      |                           ^
a.cc:20:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |                 clock[p.fs][p.sc].push_back(i*3600+j*60+k);
      |                                 ^
a.cc:20:35: error: request for member 'push_back' in '*(clock + (((sizetype)p.std::pair<int, int>::first) + ((sizetype)p.std::pair<int, int>::second)))', which is of non-class type 'clock_t() noexcept' {aka 'long int() noexcept'}
   20 |                 clock[p.fs][p.sc].push_back(i*3600+j*60+k);
      |                                   ^~~~~~~~~
a.cc:38:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                         ^
a.cc:6:32: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
a.cc:38:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                               ^
a.cc:6:32: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
a.cc:38:49: error: request for member 'size' in '*(clock + (((sizetype)p.std::pair<int, int>::first) + ((sizetype)p.std::pair<int, int>::second)))', which is of non-class type 'clock_t() noexcept' {aka 'long int() noexcept'}
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                 ^~~~
a.cc:6:32: note: in definition of macro 'rep'
    6 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^
a.cc:38:79: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                                               ^
a.cc:38:85: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                                                     ^
a.cc:38:88: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                                                        ^
a.cc:38:68: error: no matching function for call to 'push_back(clock_t (&)() noexcept)'
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' (near match)
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   conversion of argument 1 would be ill-formed:
a.cc:38:88: error: invalid conversion from 'clock_t (*)() noexcept' {aka 'long int (*)() noexcept'} to 'std::vector<int>::value_type' {aka 'int'} [-fpermissive]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                                     ~~~~~~~~~~~~~~~~~~~^
      |                                                                                        |
      |                                                                                        clock_t (*)() noexcept {aka long int (*)() noexcept}
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' (near match)
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   conversion of argument 1 would be ill-formed:
a.cc:38:88: error: invalid conversion from 'clock_t (*)() noexcept' {aka 'long int (*)() noexcept'} to 'std::vector<int>::value_type' {aka 'int'} [-fpermissive]
   38 |                         rep(j,clock[p.fs][p.sc].size()) t.push_back(clock[p.fs][p.sc][j]);
      |                                                                     ~~~~~~~~~~~~~~~~~~~^
      |                                                                                        |
      |                                                                                        clock_t (*)() noexcept {aka long int (*)() noexcept}
a.cc:47:84: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                                    ^
a.cc:9:16: note: in definition of macro 'all'
    9 | #define all(c) c.begin(),c.end()
      |                ^
a.cc:47:90: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                                          ^
a.cc:9:16: note: in definition of macro 'all'
    9 | #define all(c) c.begin(),c.end()
      |                ^
a.cc:9:18: error: request for member 'begin' in '*(clock + (((sizetype)p.std::pair<int, int>::first) + ((sizetype)p.std::pair<int, int>::second)))', which is of non-class type 'clock_t() noexcept' {aka 'long int() noexcept'}
    9 | #define all(c) c.begin(),c.end()
      |                  ^~~~~
a.cc:47:70: note: in expansion of macro 'all'
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                      ^~~
a.cc:47:84: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                                    ^
a.cc:9:26: note: in definition of macro 'all'
    9 | #define all(c) c.begin(),c.end()
      |                          ^
a.cc:47:90: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                                          ^
a.cc:9:26: note: in definition of macro 'all'
    9 | #define all(c) c.begin(),c.end()
      |                          ^
a.cc:9:28: error: request for member 'end' in '*(clock + (((sizetype)p.std::pair<int, int>::first) + ((sizetype)p.std::pair<int, int>::second)))', which is of non-class type 'clock_t() noexcept' {aka 'long int() noexcept'}
    9 | #define all(c) c.begin(),c.end()
      |                            ^~~
a.cc:47:70: note: in expansion of macro 'all'
   47 |                                 vector<int>::iterator it=lower_bound(all(clock[p.fs][p.sc]),t[i]);
      |                                                                      ^~~
a.cc:48:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |                                 if(it==clock[p.fs][p.sc].end()){
      |                                                  ^
a.cc:48:56: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |                                 if(it==clock[p.fs][p.sc].end()){
      |                                                        ^
a.cc:48:58: error: request for member 'end' in '*(clock + (((sizetype)p.std::pair<int, int>::first) + ((sizetype)p.std::pair<int, int>::second)))', which is of non-class type 'clock_t() noexcept' {aka 'long int() noexcept'}
   48 |                                 if(it==clock[p.fs][p.sc].end()){
      |                                                          ^~~