Submission #660847

#TimeUsernameProblemLanguageResultExecution timeMemory
660847rukashiiMeteors (POI11_met)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 3e5 + 2; int n, m, a[maxn], q, tree[maxn], ans[maxn], bad[maxn]; vector <pair <int, pair <int, int>>> query; vector <int> st[maxn], opt[maxn]; void update(int pos, int val) { for (int i = pos; i <= m; i += (i & (-i))) { tree[i] += val; } } int get(int pos) { int ret = 0; for (int i = pos; i >= 1; i -= (i & (-i))) { ret += tree[i]; } return ret; } signed main() { ios::sync_with_stdio(0); cin.tie(0); memset(ans, -1, sizeof(ans)); memset(bad, -1, sizeof(bad)); //freopen("input.inp", "r", stdin); //freopen("output.out", "w", stdout); cin >> n >> m; for (int i = 1, t; i <= m; i++) { cin >> t; st[t].push_back(i); } for (int i = 1; i <= n; i++) cin >> a[i]; cin >> q; for (int i = 1; i <= q; i++) { int l, r, w; cin >> l >> r >> w; query.push_back({l, {r, w}}); } for (int i = 1; i <= n; i++) opt[(1 + q) / 2].push_back(i); queue <pair <int, int>> qe; qe.push({1, q}); while (qe.size()) { auto [l, r] = qe.front(); qe.pop(); memset(tree, 0, sizeof(tree)); if (l >= r) continue; int mid = (l + r) / 2; if (!opt[mid].size()) continue; int l_mid = (l + mid) / 2; int r_mid = (mid + 1 + r) / 2; qe.push({l, mid}); qe.push({mid + 1, r}); for (int i = 0; i < min(mid, query.size()); i++) { int u = query[i].first; pair <int, int> tam = query[i].second; int v = tam.first, f = tam.second; if (u <= v) { update(u, f); update(v + 1, -f); } else { update(1, f); update(v + 1, -f); update(u, f); } } for (int p : opt[mid]) { bool skip = 0; int sum = 0; for (int child : st[p]) { sum += get(child); } if (sum < a[p]) { opt[r_mid].push_back(p); if (bad[p] == -1) bad[p] = 1; } else opt[l_mid].push_back(p), ans[p] = mid, bad[p] = 0; } opt[mid].clear(); } memset(tree, 0, sizeof(tree)); for (int i = 0; i < min(q, query.size()); i++) { int u = query[i].first; pair <int, int> tam = query[i].second; int v = tam.first, f = tam.second; if (u <= v) { update(u, f); update(v + 1, -f); } else { update(1, f); update(v + 1, -f); update(u, f); } } for (int i = 1; i < q; i++) { for (int tmp : opt[i]) { if (!bad[tmp]) ans[tmp] = i; } } for (int tmp : opt[q]) { int sum = 0; for (int child : st[tmp]) { sum += get(child); } if (sum >= a[tmp]) ans[tmp] = q; } for (int i = 1; i <= n; i++) if (ans[i] == -1) cout << "NIE\n"; else cout << ans[i] << '\n'; }

Compilation message (stderr)

met.cpp: In function 'int main()':
met.cpp:89:44: error: no matching function for call to 'min(long long int&, std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type)'
   89 |   for (int i = 0; i < min(mid, query.size()); i++)
      |                                            ^
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 met.cpp:1:
/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:
met.cpp:89:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'})
   89 |   for (int i = 0; i < min(mid, query.size()); i++)
      |                                            ^
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 met.cpp:1:
/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:
met.cpp:89:44: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'})
   89 |   for (int i = 0; i < min(mid, query.size()); i++)
      |                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/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:
met.cpp:89:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   89 |   for (int i = 0; i < min(mid, query.size()); i++)
      |                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/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:
met.cpp:89:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   89 |   for (int i = 0; i < min(mid, query.size()); i++)
      |                                            ^
met.cpp:111:9: warning: unused variable 'skip' [-Wunused-variable]
  111 |    bool skip = 0;
      |         ^~~~
met.cpp:133:41: error: no matching function for call to 'min(long long int&, std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type)'
  133 |  for (int i = 0; i < min(q, query.size()); i++)
      |                                         ^
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 met.cpp:1:
/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:
met.cpp:133:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'})
  133 |  for (int i = 0; i < min(q, query.size()); i++)
      |                                         ^
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 met.cpp:1:
/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:
met.cpp:133:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'})
  133 |  for (int i = 0; i < min(q, query.size()); i++)
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/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:
met.cpp:133:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  133 |  for (int i = 0; i < min(q, query.size()); i++)
      |                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from met.cpp:1:
/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:
met.cpp:133:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  133 |  for (int i = 0; i < min(q, query.size()); i++)
      |                                         ^