답안 #926333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926333 2024-02-12T19:35:37 Z VMaksimoski008 Meteors (POI11_met) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
 
struct BIT {
    int n;
    vector<int> tree;
 
    void config(int _n) {
        n = _n + 2;
        tree.resize(_n+10);
    }
 
    void add(int p, int v) {
        for(p++; p<n; p+=p&-p) tree[p] += v;
    }
 
    ll query(int p) {
        ll ans = 0;
        for(p++; p>0; p-=p&-p) ans += tree[p];
        return ans;
    }
 
	ll sum(int l, int r) { return query(r) - query(l-1); }
    void clear() { for(auto &x : tree) x = 0; }
};
 
struct Query { int l, r, x; };
 
int main() {
    int n, m, it, i, k;
    ll total = 0;
    cin >> n >> m;
 
    vector<int> owner[n+5];
    for(i=1; i<=m; i++) {
        int x;
        cin >> x;
        owner[x].push_back(i);
    }
 
    int req[n+5];
    for(i=1; i<=n; i++) cin >> req[i];
 
    cin >> k;
    Query qus[k+5], q;
    for(i=1; i<=k; i++)
        cin >> qus[i].l >> qus[i].r >> qus[i].x;
 
    vector<int> L(n+5, 1), R(n+5, k+1);
    bool changed = true;
 
    BIT bit;
    bit.config(m+1);
    stack<int> to_check(k+2);
    
    while(changed) {
        changed = false;
 
        bit.clear();
 
        for(i=1; i<=n; i++)
            if(L[i] != R[i]) to_check[(L[i]+R[i])/2].push(i);
 
        for(it=1; it<=k; it++) {
            q = qus[it];
 
            if(q.l <= q.r) {
                bit.add(q.l, q.x);
                bit.add(q.r+1, -q.x);
            } else {
                bit.add(q.l, q.x);
                bit.add(m+1, -q.x);
 
                bit.add(1, q.x);
                bit.add(q.r+1, -q.x);
            }
 
            while(!to_check[it].empty()) {
                changed = true;
 
                int u = to_check[it].top();
                to_check[it].pop();
 
                total = 0;
                for(int &x : owner[u]) {
                    total += bit.query(x);
                    if(total > req[u]) break;
                }
 
                if(total >= req[u]) R[u] = it;
                else L[u] = it + 1;
            }
        }
    }
 
    for(i=1; i<=n; i++) {
        if(L[i] <= k) cout << L[i] << '\n';
        else cout << "NIE\n";
    }
    return 0;
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:58:28: error: no matching function for call to 'std::stack<int>::stack(int)'
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:191:2: note: candidate: 'template<class _Alloc, class _Requires> std::stack<_Tp, _Sequence>::stack(std::stack<_Tp, _Sequence>&&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  191 |  stack(stack&& __q, const _Alloc& __a)
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:191:2: note:   template argument deduction/substitution failed:
met.cpp:58:28: note:   candidate expects 2 arguments, 1 provided
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:187:2: note: candidate: 'template<class _Alloc, class _Requires> std::stack<_Tp, _Sequence>::stack(const std::stack<_Tp, _Sequence>&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  187 |  stack(const stack& __q, const _Alloc& __a)
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:187:2: note:   template argument deduction/substitution failed:
met.cpp:58:28: note:   candidate expects 2 arguments, 1 provided
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:183:2: note: candidate: 'template<class _Alloc, class _Requires> std::stack<_Tp, _Sequence>::stack(_Sequence&&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  183 |  stack(_Sequence&& __c, const _Alloc& __a)
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:183:2: note:   template argument deduction/substitution failed:
met.cpp:58:28: note:   candidate expects 2 arguments, 1 provided
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:179:2: note: candidate: 'template<class _Alloc, class _Requires> std::stack<_Tp, _Sequence>::stack(const _Sequence&, const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  179 |  stack(const _Sequence& __c, const _Alloc& __a)
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:179:2: note:   template argument deduction/substitution failed:
met.cpp:58:28: note:   candidate expects 2 arguments, 1 provided
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:175:2: note: candidate: 'template<class _Alloc, class _Requires> std::stack<_Tp, _Sequence>::stack(const _Alloc&) [with _Alloc = _Alloc; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  175 |  stack(const _Alloc& __a)
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:175:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_stack.h: In substitution of 'template<class _Tp, class _Sequence> template<class _Alloc> using _Uses = typename std::enable_if<std::uses_allocator<_Sequence, _Alloc>::value>::type [with _Alloc = int; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]':
/usr/include/c++/10/bits/stl_stack.h:173:33:   required from here
/usr/include/c++/10/bits/stl_stack.h:127:8: error: no type named 'type' in 'struct std::enable_if<false, void>'
  127 |  using _Uses = typename
      |        ^~~~~
/usr/include/c++/10/bits/stl_stack.h:170:7: note: candidate: 'std::stack<_Tp, _Sequence>::stack(_Sequence&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  170 |       stack(_Sequence&& __c)
      |       ^~~~~
/usr/include/c++/10/bits/stl_stack.h:170:25: note:   no known conversion for argument 1 from 'int' to 'std::deque<int, std::allocator<int> >&&'
  170 |       stack(_Sequence&& __c)
      |             ~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_stack.h:166:7: note: candidate: 'std::stack<_Tp, _Sequence>::stack(const _Sequence&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  166 |       stack(const _Sequence& __c)
      |       ^~~~~
/usr/include/c++/10/bits/stl_stack.h:166:30: note:   no known conversion for argument 1 from 'int' to 'const std::deque<int, std::allocator<int> >&'
  166 |       stack(const _Sequence& __c)
      |             ~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_stack.h:162:2: note: candidate: 'template<class _Seq, class _Requires> std::stack<_Tp, _Sequence>::stack() [with _Seq = _Seq; _Requires = _Requires; _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  162 |  stack()
      |  ^~~~~
/usr/include/c++/10/bits/stl_stack.h:162:2: note:   template argument deduction/substitution failed:
met.cpp:58:28: note:   candidate expects 0 arguments, 1 provided
   58 |     stack<int> to_check(k+2);
      |                            ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from met.cpp:1:
/usr/include/c++/10/bits/stl_stack.h:99:11: note: candidate: 'std::stack<int>::stack(const std::stack<int>&)'
   99 |     class stack
      |           ^~~~~
/usr/include/c++/10/bits/stl_stack.h:99:11: note:   no known conversion for argument 1 from 'int' to 'const std::stack<int>&'
/usr/include/c++/10/bits/stl_stack.h:99:11: note: candidate: 'std::stack<int>::stack(std::stack<int>&&)'
/usr/include/c++/10/bits/stl_stack.h:99:11: note:   no known conversion for argument 1 from 'int' to 'std::stack<int>&&'
met.cpp:66:38: error: no match for 'operator[]' (operand types are 'std::stack<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   66 |             if(L[i] != R[i]) to_check[(L[i]+R[i])/2].push(i);
      |                                      ^
met.cpp:82:28: error: no match for 'operator[]' (operand types are 'std::stack<int>' and 'int')
   82 |             while(!to_check[it].empty()) {
      |                            ^
met.cpp:85:33: error: no match for 'operator[]' (operand types are 'std::stack<int>' and 'int')
   85 |                 int u = to_check[it].top();
      |                                 ^
met.cpp:86:25: error: no match for 'operator[]' (operand types are 'std::stack<int>' and 'int')
   86 |                 to_check[it].pop();
      |                         ^