답안 #920421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920421 2024-02-02T14:23:53 Z NotLinux Meteors (POI11_met) C++17
컴파일 오류
0 ms 0 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 7;
struct SEGT{
    vector < long long > t;
    int tree_size;
    const int identity_element = 0;
    long long merge(long long x , long long y){ 
        return min(inf , x + y);
    }
    void init(int x){
        tree_size = x+3;
        t.assign(2*tree_size , identity_element);
    }
    void modify(int p, int value) {  // set value at position p
        for (t[p += tree_size] += value; p > 1; p >>= 1){
            t[p>>1] = merge(t[p] , t[p^1]); 
        }
    }
    int _query(int l, int r) {  // sum on interval [l, r]
        long long res = identity_element;
        for (r+=1 , l += tree_size, r += tree_size; l < r; l >>= 1, r >>= 1) {
            if (l&1) res = merge(res , t[l++]); 
            if (r&1) res = merge(res , t[--r]); 
        }
        return res;
    }
    void rangeupdate(int l , int r , int val){
        // cout << "rangeupdate : " << l << " " << r << " " << val << endl;
        modify(l , val);
        modify(r+1 , -val);
    }
    int query(int p){
        return _query(0,p);
    }
};
void solve(){
    int n,m;cin >> n >> m;
    vector < int > devlet[n+1];
    for(int i = 1;i<=m;i++){
        int x;cin >> x;
        devlet[x].push_back(i);
    }
    int need[n+1];
    for(int i = 1;i<=n;i++){
        cin >> need[i];
    }
    int q;cin >> q;
    vector < array < int , 3 > > query(q+1);
    for(int i = 1;i<=q;i++){
        cin >> query[i][0] >> query[i][1] >> query[i][2];
    }

    vector < array < int , 3 > > paralel[q+2],nparalel[q+2];
    for(int i = 1;i<=n;i++){
        paralel[(1+q+1)/2].push_back({i,1,q+1});
    }
    SEGT fen;
    for(int i = 0;i<=21;i++){
        fen.init(m+10);
        for(int j = 1;j<=q;j++){
            if(query[j][0] <= query[j][1]){
                fen.rangeupdate(query[j][0],query[j][1],query[j][2]);
            }
            else{
                fen.rangeupdate(1,query[j][1],query[j][2]);
                fen.rangeupdate(query[j][0],m+1,query[j][2]);
            }
            // cout << "j : ";for(int k = 1;k<=m;k++)cout << fen._query(k,k) << " ";cout << endl;
            for(auto itr : paralel[j]){
                if(itr[1] == itr[2]){
                    nparalel[j].push_back(itr);
                    continue;
                }
                int cur = 0;
                for(auto itr1 : devlet[itr[0]]){
                    cur = min(inf , cur + fen.query(itr1));
                }
                if(cur >= need[itr[0]]){//r = mid;
                    int mid = (itr[1] + j)/2;
                    nparalel[mid].push_back({itr[0],itr[1],j});
                }
                else {//l = mid
                    int mid = (j+1 + itr[2])/2;
                    nparalel[mid].push_back({itr[0],j+1,itr[2]});
                }
            }
        }
        for(int j = 1;j<=q;j++){
            paralel[j].swap(nparalel[j]);
            nparalel[j].clear();
        }
    }
    int ans[n+1];
    memset(ans , -1 , sizeof(ans));
    for(int j = 1;j<=q;j++){
        for(auto itr : paralel[j]){
            ans[itr[0]] = j;
        }
    }
    for(int i = 1;i<=n;i++){
        if(ans[i] == -1)cout << "NIE" << '\n';
        else cout << ans[i] << '\n';
    }
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int testcase = 1;//cin >> testcase;
    while(testcase--)solve();
}

Compilation message

met.cpp: In function 'void solve()':
met.cpp:79:58: error: no matching function for call to 'min(const long long int&, int)'
   79 |                     cur = min(inf , cur + fen.query(itr1));
      |                                                          ^
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:3:
/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:79:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   79 |                     cur = min(inf , cur + fen.query(itr1));
      |                                                          ^
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:3:
/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:79:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   79 |                     cur = min(inf , cur + fen.query(itr1));
      |                                                          ^
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:3:
/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:79:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   79 |                     cur = min(inf , cur + fen.query(itr1));
      |                                                          ^
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:3:
/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:79:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   79 |                     cur = min(inf , cur + fen.query(itr1));
      |                                                          ^