Submission #388698

#TimeUsernameProblemLanguageResultExecution timeMemory
388698SorahISAIOI Fever (JOI21_fever)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> using namespace std; // #define int long long #define double long double using pii = pair<int, int>; template<typename T> using Prior = std::priority_queue<T>; template<typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>; #define X first #define Y second #define eb emplace_back #define ALL(x) begin(x), end(x) #define RALL(x) rbegin(x), rend(x) #define fastIO() ios_base::sync_with_stdio(0), cin.tie(0) vector<pii> city; vector<int> infect, dir; map<int, vector<pii>> meet; /// (time |-> people meet) void solve() { int n; cin >> n, city.resize(n); for (auto &[x, y] : city) cin >> x >> y; int x0 = city[0].X, y0 = city[0].Y; for (auto &[x, y] : city) x -= x0, y -= y0; auto walk = [&](int id, int t) -> pii { return {city[id].X + t * (dir[id] == 1) - t * (dir[id] == 2), city[id].Y + t * (dir[id] == 3) - t * (dir[id] == 4)}; }; int maxAns = 1; for (int d : {1, 2, 3, 4}) { /// dir: [+x, -x, +y, -y] /// infect.assign(n, 0), dir.assign(n, 0), meet.clear(); infect[0] = 1, dir[0] = d; /// assign directions /// for (int i = 1; i < n; ++i) { if (abs(city[i].X) == abs(city[i].Y)) { if (d == 1) dir[i] = city[i].X > 0 ? (city[i].Y > 0 ? 4 : 3) : 1; if (d == 2) dir[i] = city[i].X < 0 ? (city[i].Y > 0 ? 4 : 3) : 2; if (d == 3) dir[i] = city[i].Y > 0 ? (city[i].X > 0 ? 2 : 1) : 3; if (d == 4) dir[i] = city[i].Y < 0 ? (city[i].X > 0 ? 2 : 1) : 4; } if (abs(city[i].X) < abs(city[i].Y)) dir[i] = city[i].Y > 0 ? 4 : 3; if (abs(city[i].X) > abs(city[i].Y)) dir[i] = city[i].X > 0 ? 2 : 1; } /// calculate meet time for every {x, y} /// for (int i = 0; i < n; ++i) { for (int j = i+1; j < n; ++j) { int dx = abs(city[i].X - city[j].X); int dy = abs(city[i].Y - city[j].Y); if (dx == dy and walk(i, dx) == walk(j, dx)) meet[2*dx].eb(i, j); if (dx == 0 and walk(i, dy) == walk(j, 0) and walk(i, 0) == walk(j, dy)) meet[dy].eb(i, j); if (dy == 0 and walk(i, dx) == walk(j, 0) and walk(i, 0) == walk(j, dx)) meet[dx].eb(i, j); } } /// check if infection happens /// for (auto [t, vec] : meet) { for (int _ = 0; _ < 3; ++_) { for (auto [x, y] : vec) infect[x] = infect[y] = infect[x] | infect[y]; } } maxAns = max(maxAns, accumulate(ALL(infect), 0LL)); // for (int i = 0; i < n; ++i) { // if (infect[i]) cout << i << "\n"; // } } cout << maxAns << "\n"; } int32_t main() { fastIO(); int t = 1; // cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

fever.cpp: In function 'void solve()':
fever.cpp:71:58: error: no matching function for call to 'max(int&, long long int)'
   71 |         maxAns = max(maxAns, accumulate(ALL(infect), 0LL));
      |                                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from fever.cpp:2:
/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:
fever.cpp:71:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   71 |         maxAns = max(maxAns, accumulate(ALL(infect), 0LL));
      |                                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from fever.cpp:2:
/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:
fever.cpp:71:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   71 |         maxAns = max(maxAns, accumulate(ALL(infect), 0LL));
      |                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from fever.cpp:2:
/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:
fever.cpp:71:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   71 |         maxAns = max(maxAns, accumulate(ALL(infect), 0LL));
      |                                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from fever.cpp:2:
/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:
fever.cpp:71:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   71 |         maxAns = max(maxAns, accumulate(ALL(infect), 0LL));
      |                                                          ^