답안 #1007560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007560 2024-06-25T07:39:39 Z devariaota Lasers (NOI19_lasers) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long int ull;
const ll md = 998244353;
const int ukr = 6e5+10;
const int ukr2 = 3e5+10;
int read() {
    int ketek = 0; bool ne=0;
    register char c = getchar();
    while(c == ' ' or c =='\n') c =getchar();
    if(c=='-'){ne = 1; c = getchar();}
    while(c >= '0' and c <='9') { ketek = (ketek<<3)+(ketek<<1)+c-'0'; c = getchar();}
    if(ne) ketek*=-1;
    return ketek;
}   
void print(int x) {
    if (x < 0) {putchar('-');x = -x;}
    int len = 0, buf[10];
    if (x == 0) {putchar('0');return;}
    while (x > 0) {buf[len++] = x % 10; x/=10;}
    while (len > 0) {putchar('0' + buf[--len]);}
}
void File_Work(){
  freopen("test.in","r",stdin);
  freopen("test.out","w",stdout);
}
int n, m, a, b, c, d, id;
struct babi{
    ll x, y, id;
};
struct babis{
    ll x, y;
};
ll gcd(ll a, ll b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
ll pgkt(ll rnx, ll rny){
    if(rny == 0) return 1;
    ll nwrn = pgkt(rnx, rny/2);
    if(rny%2){
        return (((nwrn*nwrn)%md)*rnx)%md;
    }else{
        return (nwrn*nwrn)%md;
    }
}
vector<int> v;
string s;
ll ar[ukr2];
ll pf[ukr];
ll fak[ukr2];
ll invfak[ukr2];
void solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    for(ll i = 1; i <= n; i++){
        pf[i] = pf[i-1]+ar[i];
    }
    ll kel =  pf[n]/2;
    ll pr = 0;
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        ll l = i, r = n, res= -1;
        while(l <= r){
            ll mid = l + (r-l)/2;
            if(pf[mid]-pf[i] <= kel){
                l = mid+1;
                res = mid;
            }else{
                r = mid-1;
            }
        }
        if(pf[res]-pf[i] == kel){
            pr++;
        }
    }
    //cout << pr << endl;
    ll tdk = n-(2*pr);
    for(int i = 0; i <= min(pr, m); i++){
        ll ss = pr-i;
        //cout << ss << "\n";
        if(m < i) continue;
        ll val1 = ((fak[pr]*invfak[i])%md*invfak[pr-i])%md;
        ll val2 = (fak[m]*invfak[m-i])%md;
        ll val3 = pgkt(((m-i)*(m-i-1))%md, ss);
        ll val4 = pgkt(m-i, tdk);
        ans = (ans+(((val1*val2)%md*(val3*val4)%md))%md)%md;
        //cout << ans << "\n";
    }
    cout << ans << "\n";
    
}
void pre(){
    fak[0] = 1;
    for(ll i = 1; i <= ukr2/2; i++){
        fak[i] = (fak[i-1]*i)%md;
    }
    invfak[ukr2/2] = pgkt(fak[ukr2/2], md-2);
    for(ll i = ukr2/2-1; i >= 0; i--){
        invfak[i] = (invfak[i+1]*(i+1))%md;
    }
    //cout << invfak[2]<<pgkt(2, md-2) << "\n";
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    pre();
  int t =1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        //cout << "Case " << i << ": ";
        solve();
    }
}

Compilation message

lasers.cpp: In function 'int read()':
lasers.cpp:11:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |     register char c = getchar();
      |                   ^
lasers.cpp: In function 'void solve()':
lasers.cpp:83:34: error: no matching function for call to 'min(ll&, int&)'
   83 |     for(int i = 0; i <= min(pr, m); 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 lasers.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:
lasers.cpp:83:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   83 |     for(int i = 0; i <= min(pr, m); 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 lasers.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:
lasers.cpp:83:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   83 |     for(int i = 0; i <= min(pr, m); 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 lasers.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:
lasers.cpp:83:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   83 |     for(int i = 0; i <= min(pr, m); 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 lasers.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:
lasers.cpp:83:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   83 |     for(int i = 0; i <= min(pr, m); i++){
      |                                  ^
lasers.cpp: In function 'void File_Work()':
lasers.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   freopen("test.in","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
lasers.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   freopen("test.out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~