답안 #954496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954496 2024-03-28T04:39:44 Z vjudge1 Žarulje (COI15_zarulje) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#pragma GCC optimize(2)

const int M=1e9+7,N=1<<18;
#define L l.top()
#define R r.top()
int H[N],fac[N],inv[N],res[N];
stack<int>kill[N],l,r;
gp_hash_table<int,int>mp1,mp2;
int pw(int x,int k=M-2){
    if(!k) return 1;
    int y=pw(x,k/2);
    y=y*y%M;
    if(k&1)y=y*x%M;
    return y;
}
int C(int a,int b){
    return fac[a+b]*inv[b]%M*inv[a]%M;
}
int get(int x){
    return C(mp1[x],mp2[x]);
}
signed main(){
    l.push(0),r.push(0);
    cin.tie(0)->sync_with_stdio(0);
    fac[0]=1;
    for(int i=1;i<N;i++)
        fac[i]=fac[i-1]*i%M;
    inv[N-1]=pw(fac[N-1]);
    res[1]=1;
    for(int i=N;--i;)
        inv[i-1]=inv[i]*i%M;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>H[i];
    for(int i=n;i>1;mp2[H[i]]++,r.push(H[i--]))
        while(R>H[i])
            kill[i].push(R),mp2[R]--,r.pop();
    for(int i=2;i<=n;i++) {
        res[i]=res[i-1];
        while(L>H[i-1])
            res[i]=res[i]*pw(get(L))%M,mp1[L]--,res[i]=res[i]*get(L)%M,l.pop();
        res[i]=res[i]*pw(get(R))%M,mp2[R]--,res[i]=res[i]*get(R)%M,r.pop();
        l.push(H[i-1]),res[i]=res[i]*pw(get(L))%M,mp1[L]++,res[i]=res[i]*get(L)%M;
        while(kill[i+1].size())
            r.push(kill[i+1].top()),res[i]=res[i]*pw(get(R))%M,mp2[R]++,res[i]=res[i]*get(R)%M,kill[i+1].pop();
    }
    while(k--){
        int x;
        cin>>x;
        cout<<res[x]<<'\n';
    }
}

Compilation message

zarulje.cpp:12:17: error: 'std::stack<long long int> kill [262144]' redeclared as different kind of entity
   12 | stack<int>kill[N],l,r;
      |                 ^
In file included from /usr/include/c++/10/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:43,
                 from zarulje.cpp:1:
/usr/include/signal.h:112:12: note: previous declaration 'int kill(__pid_t, int)'
  112 | extern int kill (__pid_t __pid, int __sig) __THROW;
      |            ^~~~
zarulje.cpp: In function 'int main()':
zarulje.cpp:43:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   43 |             kill[i].push(R),mp2[R]--,r.pop();
      |                   ^
zarulje.cpp:43:21: error: request for member 'push' in '*(kill + ((sizetype)i))', which is of non-class type 'int(__pid_t, int) noexcept' {aka 'int(int, int) noexcept'}
   43 |             kill[i].push(R),mp2[R]--,r.pop();
      |                     ^~~~
zarulje.cpp:50:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   50 |         while(kill[i+1].size())
      |                       ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
zarulje.cpp:50:25: error: request for member 'size' in '*(kill + (((sizetype)i) + 1))', which is of non-class type 'int(__pid_t, int) noexcept' {aka 'int(int, int) noexcept'}
   50 |         while(kill[i+1].size())
      |                         ^~~~
zarulje.cpp:51:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |             r.push(kill[i+1].top()),res[i]=res[i]*pw(get(R))%M,mp2[R]++,res[i]=res[i]*get(R)%M,kill[i+1].pop();
      |                            ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
zarulje.cpp:51:30: error: request for member 'top' in '*(kill + (((sizetype)i) + 1))', which is of non-class type 'int(__pid_t, int) noexcept' {aka 'int(int, int) noexcept'}
   51 |             r.push(kill[i+1].top()),res[i]=res[i]*pw(get(R))%M,mp2[R]++,res[i]=res[i]*get(R)%M,kill[i+1].pop();
      |                              ^~~
zarulje.cpp:51:104: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |             r.push(kill[i+1].top()),res[i]=res[i]*pw(get(R))%M,mp2[R]++,res[i]=res[i]*get(R)%M,kill[i+1].pop();
      |                                                                                                        ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
zarulje.cpp:51:106: error: request for member 'pop' in '*(kill + (((sizetype)i) + 1))', which is of non-class type 'int(__pid_t, int) noexcept' {aka 'int(int, int) noexcept'}
   51 |             r.push(kill[i+1].top()),res[i]=res[i]*pw(get(R))%M,mp2[R]++,res[i]=res[i]*get(R)%M,kill[i+1].pop();
      |                                                                                                          ^~~