Submission #67056

# Submission time Handle Problem Language Result Execution time Memory
67056 2018-08-13T09:26:53 Z MrTEK Maxcomp (info1cup18_maxcomp) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e3 + 5;
const int M = 4;
const int SQ = 350;
const int MOD = 998244353;

typedef pair <int,int> pii;

unordered_set <pair <int,pii> > S;

int n,m,mat[N][N],vis[N][N],ans = -INF,way[4][2] = {{1,0},{0,1},{0,-1},{-1,0}};

int main() {
	scanf("%d %d",&n,&m);
	for (int i = 1 ; i <= n ; i++)
		for (int j = 1 ; j <= m ; j++) {
			scanf("%d",&mat[i][j]);
			vis[i][j] = -INF;
			S.insert(mp(-mat[i][j],mp(i,j)));
		}
	while(len(S)) {
		auto temp = *S.begin();
		S.erase(S.begin());
		int val = -temp.fi, x = temp.sc.fi, y = temp.sc.sc;
		if (vis[x][y] > val) continue;
		ans = max(ans,val - mat[x][y] - 1);
		for (int i = 0 ; i < 4 ; i++) {
			int nx = x + way[i][0] , ny = y + way[i][1];
			if (nx > 0 && nx <= n && ny > 0 && ny <= m && val - 1 > vis[nx][ny]) {
				vis[nx][ny] = val - 1;
				S.insert(mp(-(val - 1),mp(nx,ny)));
			}
		}
	}
	printf("%d\n",ans);

}

Compilation message

In file included from /usr/include/c++/7/bits/hashtable.h:35:0,
                 from /usr/include/c++/7/unordered_map:47,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:117,
                 from maxcomp.cpp:1:
/usr/include/c++/7/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > >':
/usr/include/c++/7/type_traits:143:12:   required from 'struct std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > >'
/usr/include/c++/7/type_traits:154:31:   required from 'struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
/usr/include/c++/7/bits/unordered_set.h:98:63:   required from 'class std::unordered_set<std::pair<int, std::pair<int, int> > >'
maxcomp.cpp:29:33:   required from here
/usr/include/c++/7/bits/hashtable_policy.h:87:34: error: no match for call to '(const std::hash<std::pair<int, std::pair<int, int> > >) (const std::pair<int, std::pair<int, int> >&)'
  noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
           ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/nested_exception.h:40,
                 from /usr/include/c++/7/exception:143,
                 from /usr/include/c++/7/ios:39,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from maxcomp.cpp:1:
/usr/include/c++/7/type_traits: In instantiation of 'struct std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >':
/usr/include/c++/7/bits/unordered_set.h:98:63:   required from 'class std::unordered_set<std::pair<int, std::pair<int, int> > >'
maxcomp.cpp:29:33:   required from here
/usr/include/c++/7/type_traits:154:31: error: 'value' is not a member of 'std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > >'
     : public __bool_constant<!bool(_Pp::value)>
                               ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:118,
                 from maxcomp.cpp:1:
/usr/include/c++/7/bits/unordered_set.h: In instantiation of 'class std::unordered_set<std::pair<int, std::pair<int, int> > >':
maxcomp.cpp:29:33:   required from here
/usr/include/c++/7/bits/unordered_set.h:98:63: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc>  _Hashtable;
                                                               ^~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:105:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::key_type key_type;
                                             ^~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:106:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::value_type value_type;
                                               ^~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:107:43: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::hasher hasher;
                                           ^~~~~~
/usr/include/c++/7/bits/unordered_set.h:108:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::key_equal key_equal;
                                              ^~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:109:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::allocator_type allocator_type;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:114:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::pointer  pointer;
                                             ^~~~~~~
/usr/include/c++/7/bits/unordered_set.h:115:50: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::const_pointer const_pointer;
                                                  ^~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:116:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::reference  reference;
                                               ^~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:117:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::const_reference const_reference;
                                                    ^~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:118:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::iterator  iterator;
                                              ^~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:119:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::const_iterator const_iterator;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:120:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::local_iterator local_iterator;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:121:57: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::const_local_iterator const_local_iterator;
                                                         ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:122:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::size_type  size_type;
                                               ^~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:123:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       typedef typename _Hashtable::difference_type difference_type;
                                                    ^~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:282:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:375:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
  emplace(_Args&&... __args)
  ^~~~~~~
/usr/include/c++/7/bits/unordered_set.h:419:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       insert(const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/unordered_set.h:423:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       insert(value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/unordered_set.h:478:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       insert(initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/unordered_set.h:679:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       equal_range(const key_type& __x)
       ^~~~~~~~~~~
/usr/include/c++/7/bits/unordered_set.h:683:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<std::hash<std::pair<int, std::pair<int, int> > > >, std::__detail::__is_noexcept_hash<std::pair<int, std::pair<int, int> >, std::hash<std::pair<int, std::pair<int, int> > > > > >'
       equal_range(const key_type& __x) const
       ^~~~~~~~~~~
maxcomp.cpp: In function 'int main()':
maxcomp.cpp:39:35: error: no matching function for call to 'std::unordered_set<std::pair<int, std::pair<int, int> > >::insert(std::pair<int, std::pair<int, int> >)'
    S.insert(mp(-mat[i][j],mp(i,j)));
                                   ^
In file included from /usr/include/c++/7/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:118,
                 from maxcomp.cpp:1:
/usr/include/c++/7/bits/unordered_set.h:467:2: note: candidate: template<class _InputIterator> void std::unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Value = std::pair<int, std::pair<int, int> >; _Hash = std::hash<std::pair<int, std::pair<int, int> > >; _Pred = std::equal_to<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >]
  insert(_InputIterator __first, _InputIterator __last)
  ^~~~~~
/usr/include/c++/7/bits/unordered_set.h:467:2: note:   template argument deduction/substitution failed:
maxcomp.cpp:39:35: note:   candidate expects 2 arguments, 1 provided
    S.insert(mp(-mat[i][j],mp(i,j)));
                                   ^
maxcomp.cpp:6:23: error: 'class std::unordered_set<std::pair<int, std::pair<int, int> > >' has no member named 'size'
 #define len(a) (int)a.size()
                       ^
maxcomp.cpp:41:8: note: in expansion of macro 'len'
  while(len(S)) {
        ^~~
maxcomp.cpp:42:18: error: 'class std::unordered_set<std::pair<int, std::pair<int, int> > >' has no member named 'begin'
   auto temp = *S.begin();
                  ^~~~~
maxcomp.cpp:43:5: error: 'class std::unordered_set<std::pair<int, std::pair<int, int> > >' has no member named 'erase'
   S.erase(S.begin());
     ^~~~~
maxcomp.cpp:43:13: error: 'class std::unordered_set<std::pair<int, std::pair<int, int> > >' has no member named 'begin'
   S.erase(S.begin());
             ^~~~~
maxcomp.cpp:45:11: error: 'x' was not declared in this scope
   if (vis[x][y] > val) continue;
           ^
maxcomp.cpp:45:14: error: 'y' was not declared in this scope
   if (vis[x][y] > val) continue;
              ^
maxcomp.cpp:46:27: error: 'x' was not declared in this scope
   ans = max(ans,val - mat[x][y] - 1);
                           ^
maxcomp.cpp:46:30: error: 'y' was not declared in this scope
   ans = max(ans,val - mat[x][y] - 1);
                              ^
maxcomp.cpp:49:29: error: 'ny' was not declared in this scope
    if (nx > 0 && nx <= n && ny > 0 && ny <= m && val - 1 > vis[nx][ny]) {
                             ^~
maxcomp.cpp:49:29: note: suggested alternative: 'nx'
    if (nx > 0 && nx <= n && ny > 0 && ny <= m && val - 1 > vis[nx][ny]) {
                             ^~
                             nx
maxcomp.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
maxcomp.cpp:37:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&mat[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~