제출 #1271905

#제출 시각아이디문제언어결과실행 시간메모리
1271905mfong_123abcHappiness (Balkan15_HAPPINESS)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #include "happiness.h" // int n,m,q,e,k,a[1021000]={0},t[4021000]={0},sum=0,b[10]; // void build(int v, int l, int r){ // if(l==r){ t[v]=a[l]; return; } // int mid=(l+r)/2; // build(v*2,l,mid); build(v*2+1,mid+1,r); // t[v]=t[v*2]+t[v*2+1]; // // cout<<v<<" "<<l<<" "<<r<<" "<<t[v]<<" "<<t[v*2]<<" "<<t[v*2+1]<<"\n"; // } // int query(int v, int l, int r, int tl, int tr){ // if(l>tr||r<tl)return 0; // if(tl<=l&&tr>=r)return t[v]; // int mid=(l+r)/2; // // cout<<v<<" "<<l<<" "<<r<<" "<<t[v]<<"\n"; // return query(v*2,l,mid,tl,tr)+query(v*2+1,mid+1,r,tl,tr); // } // void update(int v, int l, int r, int pos, int val){ // // cout<<v<<" "<<l<<" "<<r<<" "<<pos<<" "<<val<<"\n"; // if(pos<l||pos>r)return; // if(l==r){ // t[v]+=val; // return; // } // int mid=(l+r)/2; // update(v*2,l,mid,pos,val); update(v*2+1,mid+1,r,pos,val); // t[v]=t[v*2]+t[v*2+1]; // } // bool check(){ // int w=1; // while(w<=sum){ // int res=query(1,1,m,1,w); // // cout<<w<<" "<<res<<"\n"; // if(res<w)return false; // w=res+1; // } // return true; // } bool init(int coinsCount, long long maxCoinSize, long long coins[]) { n=coinsCount; m=maxCoinSize; for(int i=1;i<=n;i++){int v=coins[i-1]; cin>>v; a[v]+=v; sum+=v; } build(1,1,m); return check(); } bool is_happy(int event, int coinsCount, long long coins[]) { e=event; k=coinsCount; for(int i=1;i<=k;i++)b[i]=coins[i-1]; for(int i=1;i<=k;i++)cin>>b[i]; for(int i=1;i<=k;i++)sum+=e*b[i]; for(int i=1;i<=k;i++)update(1,1,m,b[i],e*b[i]); return check(); }

컴파일 시 표준 에러 (stderr) 메시지

happiness.cpp: In function 'bool init(long long int, long long int, long long int*)':
happiness.cpp:48:5: error: 'n' was not declared in this scope; did you mean 'yn'?
   48 |     n=coinsCount; m=maxCoinSize; for(int i=1;i<=n;i++){int v=coins[i-1]; cin>>v; a[v]+=v; sum+=v; }
      |     ^
      |     yn
happiness.cpp:48:19: error: 'm' was not declared in this scope; did you mean 'tm'?
   48 |     n=coinsCount; m=maxCoinSize; for(int i=1;i<=n;i++){int v=coins[i-1]; cin>>v; a[v]+=v; sum+=v; }
      |                   ^
      |                   tm
happiness.cpp:48:82: error: 'a' was not declared in this scope
   48 |     n=coinsCount; m=maxCoinSize; for(int i=1;i<=n;i++){int v=coins[i-1]; cin>>v; a[v]+=v; sum+=v; }
      |                                                                                  ^
happiness.cpp:48:91: error: 'sum' was not declared in this scope
   48 |     n=coinsCount; m=maxCoinSize; for(int i=1;i<=n;i++){int v=coins[i-1]; cin>>v; a[v]+=v; sum+=v; }
      |                                                                                           ^~~
happiness.cpp:49:5: error: 'build' was not declared in this scope
   49 |     build(1,1,m);
      |     ^~~~~
happiness.cpp:50:12: error: 'check' was not declared in this scope
   50 |     return check();
      |            ^~~~~
happiness.cpp: In function 'bool is_happy(long long int, long long int, long long int*)':
happiness.cpp:54:5: error: 'e' was not declared in this scope; did you mean 'std::numbers::e'?
   54 |     e=event; k=coinsCount; for(int i=1;i<=k;i++)b[i]=coins[i-1];
      |     ^
      |     std::numbers::e
In file included from /usr/include/c++/13/bits/max_size_type.h:37,
                 from /usr/include/c++/13/bits/ranges_base.h:39,
                 from /usr/include/c++/13/bits/ranges_algobase.h:38,
                 from /usr/include/c++/13/bits/ranges_algo.h:38,
                 from /usr/include/c++/13/algorithm:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from happiness.cpp:1:
/usr/include/c++/13/numbers:122:27: note: 'std::numbers::e' declared here
  122 |   inline constexpr double e = e_v<double>;
      |                           ^
happiness.cpp:54:14: error: 'k' was not declared in this scope
   54 |     e=event; k=coinsCount; for(int i=1;i<=k;i++)b[i]=coins[i-1];
      |              ^
happiness.cpp:54:49: error: 'b' was not declared in this scope
   54 |     e=event; k=coinsCount; for(int i=1;i<=k;i++)b[i]=coins[i-1];
      |                                                 ^
happiness.cpp:55:31: error: 'b' was not declared in this scope
   55 |     for(int i=1;i<=k;i++)cin>>b[i];
      |                               ^
happiness.cpp:56:26: error: 'sum' was not declared in this scope
   56 |     for(int i=1;i<=k;i++)sum+=e*b[i];
      |                          ^~~
happiness.cpp:56:33: error: 'b' was not declared in this scope
   56 |     for(int i=1;i<=k;i++)sum+=e*b[i];
      |                                 ^
happiness.cpp:57:37: error: 'm' was not declared in this scope
   57 |     for(int i=1;i<=k;i++)update(1,1,m,b[i],e*b[i]);
      |                                     ^
happiness.cpp:57:39: error: 'b' was not declared in this scope
   57 |     for(int i=1;i<=k;i++)update(1,1,m,b[i],e*b[i]);
      |                                       ^
happiness.cpp:57:26: error: 'update' was not declared in this scope
   57 |     for(int i=1;i<=k;i++)update(1,1,m,b[i],e*b[i]);
      |                          ^~~~~~
happiness.cpp:58:12: error: 'check' was not declared in this scope
   58 |     return check();
      |            ^~~~~