Submission #556933

#TimeUsernameProblemLanguageResultExecution timeMemory
556933shahriarkhanMeteors (POI11_met)C++14
Compilation error
0 ms0 KiB
//Problem Name : Meteors //Link : https://oj.uz/problem/view/POI11_met //Circular 1 based BIT #include<bits/stdc++.h> using namespace std ; struct BIT { int n ; vector<long long> bit ; void init(int _n) { n = _n ; bit = vector<long long>(n+5,0) ; } int low_bit(int idx) { return idx&(-idx) ; } void add(int idx , long long val) { for(; idx <= n ; idx += low_bit(idx)) { bit[idx] += val ; } } void update(int l , int r , long long val) { add(r + 1 , -val) , add(l , val) ; if(l>r) add(1,val) , add(n+1,-val) ; } long long query(int idx) { long long ret = 0 ; for(; idx > 0 ; idx -= low_bit(idx)) { ret += bit[idx] ; } return ret ; } } B ; int n , m , k , o[MX] , ans[MX] ; long long p[MX] ; vector<int> owner[MX] ; vector<query> q ; void palbs(int low , int high , vector<int> &vals) { if(low>high) return ; if(vals.empty()) return ; int mid = (low+high)>>1 ; for(int i = low ; i <= mid ; ++i) { B.update(q[i].l,q[i].r,q[i].val) ; } vector<int> ok , not_ok ; for(int c : vals) { unsigned long long sum = 0 ; for(int land : owner[c]) { sum += B.query(land) ; } if(sum>=p[c]) ans[c] = mid , ok.push_back(c) ; else { p[c] -= sum ; not_ok.push_back(c) ; } } for(int i = low ; i <= mid ; ++i) { B.update(q[i].l,q[i].r,-q[i].val) ; } vals.clear() ; if(low==high) return ; palbs(low,mid,ok) ; palbs(mid+1,high,not_ok) ; } int main() { vector<int> v ; scanf("%d%d",&n,&m) ; B.init(m+2) ; for(int i = 1 ; i <= m ; ++i) { scanf("%d",&o[i]) ; owner[o[i]].push_back(i) ; } for(int i = 1 ; i <= n ; ++i) { scanf("%lld",&p[i]) ; ans[i] = -1 ; v.push_back(i) ; } scanf("%d",&k) ; for(int i = 1 ; i <= k ; ++i) { int l , r ; long long a ; scanf("%d%d%lld",&l,&r,&a) ; q.push_back({l,r,a}) ; } palbs(0,k-1,v) ; for(int i = 1 ; i <= n ; ++i) { if(ans[i]>=0) printf("%d\n",ans[i]+1) ; else puts("NIE") ; } return 0 ; }

Compilation message (stderr)

met.cpp:43:19: error: 'MX' was not declared in this scope
   43 | int n , m , k , o[MX] , ans[MX] ;
      |                   ^~
met.cpp:43:29: error: 'MX' was not declared in this scope
   43 | int n , m , k , o[MX] , ans[MX] ;
      |                             ^~
met.cpp:45:13: error: 'MX' was not declared in this scope
   45 | long long p[MX] ;
      |             ^~
met.cpp:47:19: error: 'MX' was not declared in this scope
   47 | vector<int> owner[MX] ;
      |                   ^~
met.cpp:49:8: error: 'query' was not declared in this scope
   49 | vector<query> q ;
      |        ^~~~~
met.cpp:49:13: error: template argument 1 is invalid
   49 | vector<query> q ;
      |             ^
met.cpp:49:13: error: template argument 2 is invalid
met.cpp: In function 'void palbs(int, int, std::vector<int>&)':
met.cpp:58:19: error: invalid types 'int[int]' for array subscript
   58 |         B.update(q[i].l,q[i].r,q[i].val) ;
      |                   ^
met.cpp:58:26: error: invalid types 'int[int]' for array subscript
   58 |         B.update(q[i].l,q[i].r,q[i].val) ;
      |                          ^
met.cpp:58:33: error: invalid types 'int[int]' for array subscript
   58 |         B.update(q[i].l,q[i].r,q[i].val) ;
      |                                 ^
met.cpp:64:24: error: 'owner' was not declared in this scope
   64 |         for(int land : owner[c])
      |                        ^~~~~
met.cpp:68:17: error: 'p' was not declared in this scope
   68 |         if(sum>=p[c]) ans[c] = mid , ok.push_back(c) ;
      |                 ^
met.cpp:68:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |         if(sum>=p[c]) ans[c] = mid , ok.push_back(c) ;
      |                       ^~~
      |                       abs
met.cpp:77:19: error: invalid types 'int[int]' for array subscript
   77 |         B.update(q[i].l,q[i].r,-q[i].val) ;
      |                   ^
met.cpp:77:26: error: invalid types 'int[int]' for array subscript
   77 |         B.update(q[i].l,q[i].r,-q[i].val) ;
      |                          ^
met.cpp:77:34: error: invalid types 'int[int]' for array subscript
   77 |         B.update(q[i].l,q[i].r,-q[i].val) ;
      |                                  ^
met.cpp: In function 'int main()':
met.cpp:92:21: error: 'o' was not declared in this scope
   92 |         scanf("%d",&o[i]) ;
      |                     ^
met.cpp:93:9: error: 'owner' was not declared in this scope
   93 |         owner[o[i]].push_back(i) ;
      |         ^~~~~
met.cpp:97:23: error: 'p' was not declared in this scope
   97 |         scanf("%lld",&p[i]) ;
      |                       ^
met.cpp:98:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   98 |         ans[i] = -1 ;
      |         ^~~
      |         abs
met.cpp:107:11: error: request for member 'push_back' in 'q', which is of non-class type 'int'
  107 |         q.push_back({l,r,a}) ;
      |           ^~~~~~~~~
met.cpp:112:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
  112 |         if(ans[i]>=0) printf("%d\n",ans[i]+1) ;
      |            ^~~
      |            abs
met.cpp:88:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |     scanf("%d%d",&n,&m) ;
      |     ~~~~~^~~~~~~~~~~~~~
met.cpp:101:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |     scanf("%d",&k) ;
      |     ~~~~~^~~~~~~~~
met.cpp:106:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         scanf("%d%d%lld",&l,&r,&a) ;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~