제출 #568980

#제출 시각아이디문제언어결과실행 시간메모리
568980Dan4LifeHappiness (Balkan15_HAPPINESS)C++17
0 / 100
0 ms212 KiB
#include "happiness.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define pb push_back #define fi first #define se second int IND = 0; ll mx; vector<ll> segTree; vector<pair<int,int>> child; void add_node(ll v=0,int le=-1,int ri=-1){ segTree.pb(v), child.pb({le,ri}); } void update(ll i, ll v, int p=0, ll l=1, ll r=mx){ if(l==r) { segTree[p]+=v; return; } ll mid = (l+r)/2; if(i<=mid){ if(child[p].fi==-1) child[p].fi=++IND, add_node(); update(i,v,child[p].fi,l,mid); } else{ if(child[p].se==-1) child[p].se=++IND, add_node(); update(i,v,child[p].se,mid+1,r); } ll le = child[p].fi==-1?0ll:segTree[child[p].fi]; ll ri = child[p].se==-1?0ll:segTree[child[p].se]; segTree[p] = le+ri; } ll query(ll i, ll j, int p=0, ll l=1, ll r=mx){ if(i>r or j<l or i>j or p==-1) return 0ll; if(i<=l and r<=j) return segTree[p]; ll mid = (l+r)/2; ll le = child[p].fi==-1?0ll:query(i,j,child[p].fi,l,mid); ll ri = child[p].se==-1?0ll:query(i,j,child[p].se,mid+1,r); return le+ri; } bool chk(){ ll coin = 1; while(coin<=mx){ ll sum = query(1,coin); if(sum+1>mx) return true; if(query(1,sum+1)==sum) return false; coin = sum+1; } return true; } bool init(int n, ll M, ll a[]) { mx = M; add_node(); for(int i = 0; i < n; i++) update(a[i],a[i]); return chk(); } bool is_happy(int e, int n, ll a[]) { for(int i = 0; i < n; i++) update(a[i],a[i]*e); return chk(); }

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

grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...