Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX_N 16
#define INF 200000
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(n) REP(i,n)

int time[MAX_N][MAX_N+1];
int n;
int dp[ 1<< MAX_N];
//bool clear[MAX_N];

int solve(int clear)
{	
	if(dp[clear]!=0) return dp[clear];

	if(clear ==((1<<n) -1 ) )	return 0;
	
	int ans = INF;
	rep(n)
	{
		if((clear >>i)&1 )continue;
		ans =min(ans,time[i][0]+solve(clear|1<<i));
		REP(j,n)
		{
			if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
		}
	}
	//cout << ans << endl;
	return dp[clear] = ans ;
}

int main()
{	
	while(cin >> n && n )
	{
	memset(dp,0,(1<<MAX_N)*sizeof(int));
	REP(i,n)REP(j,n+1)cin >> time[i][j]; 	
	cout << solve(0) << endl;
	}
	return 0;
}

Compiler output:
a.cc:11:24: error: 'int time [16][17]' redeclared as different kind of entity
   11 | int time[MAX_N][MAX_N+1];
      |                        ^
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:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int solve(int)':
a.cc:26:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                                    ^
a.cc:26:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                                       ^
a.cc:26:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:26:25: error: no matching function for call to 'min(int&, time_t (*)(time_t*) noexcept)'
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:26:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'})
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:26:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   26 |                 ans =min(ans,time[i][0]+solve(clear|1<<i));
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                               ^
a.cc:29:68: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                                    ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:29:69: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:29:51: error: no matching function for call to 'min(int&, time_t (*)(time_t*) noexcept)'
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:51: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'})
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                         if((clear >> j)&1)ans =min(ans, time[i][j+1]+solve(clear|(1<<i)));
      |                                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:41:40: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                                        ^
a.cc:41:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                                           ^
a.cc:41:31: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'})
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                           ~~~ ^~ ~~~~~~~~~~
      |                           |               |
      |                           |               time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                           std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:41:43: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'}
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                                  ~~~~~~~~~^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:41:43: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short int' [-fpermissive]
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                                  ~~~~~~~~~^
      |                                           |
      |                                           time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:41:43: error: cannot bind rvalue '(short int)(time + (((sizetype)i) + ((sizetype)j)))' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:41:43: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'short unsigned int' [-fpermissive]
   41 |         REP(i,n)REP(j,n+1)cin >> time[i][j];
      |                                  ~~~~~~~~~^
      |                                           |
      |                                           time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:41:43: error: cannot bin