Submission #553953

#TimeUsernameProblemLanguageResultExecution timeMemory
553953elazarkorenRobots (IOI13_robots)C++17
Compilation error
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> #define x first #define y second #define all(v) v.begin(), v.end() #define chkmin(a, b) a = min(a, b) #define chkmax(a, b) a = max(a, b) #define int short using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vii; const int MAX_T = 1e4 + 5; const int MAX_A = 1000 + 5; const int MAX_B = 1000 + 5; const int infinity = 2e4; int a, b, t; const int MAX_N = 1e4 + 1e3 + 2; int f[MAX_T][MAX_A]; int c[MAX_T][MAX_A]; queue<pii> q; int e[MAX_N], label[MAX_N]; vi graph[MAX_N]; int ind[MAX_N]; int source, sink; void Push(int a, int b) { int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a])); e[a] -= x; if (a < b) c[a][b] -= x; else c[b][a] += x; if (!e[b] && b != sink) { q.push({label[a], b}); } e[b] += x; } void Relabel(int a) { label[a] = infinity; for (int neighbor : graph[a]) { if (a < neighbor && c[a][neighbor] > 0 || a > neighbor && c[neighbor][a] != f[neighbor][a]) { chkmin(label[a], int(label[neighbor] + 1)); } } } void Discharge(int a) { while (e[a]) { if (ind[a] == graph[a].size()) { Relabel(a); ind[a] = 0; } int b = graph[a][ind[a]]; if (label[b] == label[a] - 1) { if (a < b && c[a][b] > 0 || a > b && c[b][a] != f[b][a]) { Push(a, b); } } ind[a]++; } } int n; bool MaxFlow() { fill(e, e + n, 0); e[source] = infinity; for (int neighbor : graph[source]) { Push(source, neighbor); } fill(label, label + n, 0); fill(ind, ind + n, 0); label[source] = n; while (!q.empty()) { int node = q.front().y; q.pop(); Discharge(node); } return e[sink] == t; } bool Match(int time) { for (int i = 0; i < t; i++) { for (int j = 0; j < n - t; j++) { f[i][j] = 0; c[i][j] = 0; } } for (int i = 0; i < t; i++) { for (int neighbor : graph[i]) { if (neighbor != source) { f[i][neighbor] = 1; c[i][neighbor] = 1; } } f[i][source] = 1; c[i][source] = 0; } for (int i = t + 1; i <= t + a + b; i++) { f[sink][i] = time; c[sink][i] = 0; } return MaxFlow(); } int32_t putaway(int32_t A, int32_t B, int32_t T, int32_t x[], int32_t y[], int32_t w[], int32_t s[]) { a = A, b = B, t = T; n = t + a + b + 2; for (int i = 0; i < t; i++) { for (int j = 0; j < a; j++) { if (w[i] < x[j]) { graph[i].push_back(j + t + 1); graph[j + t + 1].push_back(i); } } } for (int i = 0; i < t; i++) { for (int j = 0; j < b; j++) { if (s[i] < y[j]) { graph[i].push_back(j + t + a + 1); graph[j + t + a + 1].push_back(i); } } } source = t + a + b + 1; sink = t; for (int i = 0; i < t; i++) { graph[source].push_back(i); graph[i].push_back(source); } for (int i = t + 1; i <= t + a + b; i++) { graph[sink].push_back(i); graph[i].push_back(sink); } int begin = 0, end = t + 1, mid; while (begin < end) { mid = (begin + end) >> 1; if (Match(mid)) { end = mid; } else begin = mid + 1; } if (end == t + 1) return -1; return end; } /* 3 0 6 6 2 9 4 6 8 5 7 9 1 8 5 1 8 7 */

Compilation message (stderr)

robots.cpp: In function 'void Push(short int, short int)':
robots.cpp:36:60: error: no matching function for call to 'min(short int&, int)'
   36 |     int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a]));
      |                                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
robots.cpp:36:60: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   36 |     int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a]));
      |                                                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
robots.cpp:36:60: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   36 |     int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a]));
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
robots.cpp:36:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   36 |     int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a]));
      |                                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from robots.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
robots.cpp:36:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   36 |     int x = min(e[a], (a < b ? c[a][b] : f[b][a] - c[b][a]));
      |                                                            ^
robots.cpp: In function 'void Relabel(short int)':
robots.cpp:49:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   49 |         if (a < neighbor && c[a][neighbor] > 0 || a > neighbor && c[neighbor][a] != f[neighbor][a]) {
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
robots.cpp: In function 'void Discharge(short int)':
robots.cpp:57:20: warning: comparison of integer expressions of different signedness: 'short int' and 'std::vector<short int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if (ind[a] == graph[a].size()) {
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~
robots.cpp:63:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   63 |             if (a < b && c[a][b] > 0 || a > b && c[b][a] != f[b][a]) {
      |                 ~~~~~~^~~~~~~~~~~~~~