제출 #363064

#제출 시각아이디문제언어결과실행 시간메모리
363064casperwang이상적인 도시 (IOI12_city)C++14
컴파일 에러
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> 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); } } } ll 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(); 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; }

컴파일 시 표준 에러 (stderr) 메시지

city.cpp:19:9: error: wrong number of template arguments (1, should be at least 2)
   19 | map <pii> appr;
      |         ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from city.cpp:1:
/usr/include/c++/9/bits/stl_map.h:100:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  100 |     class map
      |           ^~~
city.cpp: In function 'long long int BFS(long long int, long long int)':
city.cpp:38:3: error: 'll' was not declared in this scope
   38 |   ll sum = 0;
      |   ^~
city.cpp:40:5: error: 'sum' was not declared in this scope
   40 |     sum += dis[i];
      |     ^~~
city.cpp:41:10: error: 'sum' was not declared in this scope
   41 |   return sum;
      |          ^~~
city.cpp: In function 'void init(long long int)':
city.cpp:47:8: error: request for member 'clear' in 'appr', which is of non-class type 'int'
   47 |   appr.clear();
      |        ^~~~~
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:53:8: error: too few arguments to function 'void init(long long int)'
   53 |   init();
      |        ^
city.cpp:44:6: note: declared here
   44 | void init(int N) {
      |      ^~~~
city.cpp:55:9: error: no match for 'operator[]' (operand types are 'int' and 'std::pair<long long int, long long int>')
   55 |     appr[pii(X[i], Y[i])] = i;
      |         ^
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:63:16: error: request for member 'count' in 'appr', which is of non-class type 'int'
   63 |       if (appr.count(pii(X[i]+dx[j], Y[i]+dy[j]))) {
      |                ^~~~~
city.cpp:64:22: error: no match for 'operator[]' (operand types are 'int' and 'std::pair<long long int, long long int>')
   64 |         int id = appr[pii(X[i]+dx[j], Y[i]+dy[j])];
      |                      ^
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;
      |                                                  ^