Submission #363069

#TimeUsernameProblemLanguageResultExecution timeMemory
363069casperwangIdeal city (IOI12_city)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
#define debug(args...) kout("[ + " string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

const int MOD = 1000000000;
const int INF = 1e18;
const int MAXN = 100000;
vector <int> path[MAXN];
vector <int> deg;
vector <bool> vis;
map <pii,int> appr;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int BFS(int s, int N) {
  vector <int> dis(N, INF);
  dis[s] = 0;
  queue <int> nxt;
  nxt.push(s);
  while (nxt.size()) {
    int now = nxt.front();
    nxt.pop();
    for (int i : path[now]) {
      if (dis[i] == INF) {
        dis[i] = dis[now] + 1;
        nxt.push(i);
      }
    }
  }
  int sum = 0;
  for (int i = s+1; i < N; i++)
    sum += dis[i];
  return sum;
}

void init(int N) {
  for (int i = 0; i < N; i++)
    path[i].clear();
  appr.clear();
  deg.resize(N);
  vis.resize(N);
}

signed DistanceSum(signed N, signed *X, signed *Y) {
  init(N);
  for (int i = 0; i < N; i++)
    appr[pii(X[i], Y[i])] = i;
  int mnX = INF, mxX = 0, mnY = INF, mxY = 0;
  for (int i = 0; i < N; i++) {
    mnX = min(mnX, X[i]);
    mnY = min(mnY, Y[i]);
    mxX = max(mxX, X[i]);
    mxY = max(mxY, Y[i]);
    for (int j = 0; j < 4; j++) {
      if (appr.count(pii(X[i]+dx[j], Y[i]+dy[j]))) {
        int id = appr[pii(X[i]+dx[j], Y[i]+dy[j])];
        path[id].pb(i);
        path[i].pb(id);
      }
    }
  }
  int ans = 0;
  if ((mxX - mnX + 1) * (mxY - mnY + 1) != N) {
    for (int i = 0; i < N; i++) ans = (ans + BFS(s, N)) % MOD;
  }
  return ans;
}

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:58:24: error: no matching function for call to 'min(long long int&, int&)'
   58 |     mnX = min(mnX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
city.cpp:58:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   58 |     mnX = min(mnX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
city.cpp:58:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   58 |     mnX = min(mnX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
city.cpp:58:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |     mnX = min(mnX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
city.cpp:58:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |     mnX = min(mnX, X[i]);
      |                        ^
city.cpp:59:24: error: no matching function for call to 'min(long long int&, int&)'
   59 |     mnY = min(mnY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
city.cpp:59:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   59 |     mnY = min(mnY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
city.cpp:59:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   59 |     mnY = min(mnY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
city.cpp:59:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   59 |     mnY = min(mnY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
city.cpp:59:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   59 |     mnY = min(mnY, Y[i]);
      |                        ^
city.cpp:60:24: error: no matching function for call to 'max(long long int&, int&)'
   60 |     mxX = max(mxX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
city.cpp:60:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   60 |     mxX = max(mxX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
city.cpp:60:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   60 |     mxX = max(mxX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
city.cpp:60:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     mxX = max(mxX, X[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
city.cpp:60:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |     mxX = max(mxX, X[i]);
      |                        ^
city.cpp:61:24: error: no matching function for call to 'max(long long int&, int&)'
   61 |     mxY = max(mxY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
city.cpp:61:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   61 |     mxY = max(mxY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
city.cpp:61:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   61 |     mxY = max(mxY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
city.cpp:61:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |     mxY = max(mxY, Y[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
city.cpp:61:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |     mxY = max(mxY, Y[i]);
      |                        ^
city.cpp:72:50: error: 's' was not declared in this scope
   72 |     for (int i = 0; i < N; i++) ans = (ans + BFS(s, N)) % MOD;
      |                                                  ^