Language: C++

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

struct data
{
    int x,y,p;
};

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        data a[n];
        int tot = 1;
        for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y>>a[i].p,tot *= 3LL;
        int val[n+1];
        for(int i=0;i<=n;i++)val[i] = 1e16;
        for(int mask=0;mask<tot;mask++)
        {
            int bit[n];
            int v = mask,cnt = 0;
            vector<int> x,y;
            x.pb(0);
            y.pb(0);
            for(int i=0;i<n;i++)
            {
                bit[i] = v%3;
                v /= 3LL;
                cnt += (bit[i]>0);
                if(bit[i] == 1)y.pb(a[i].x);
                if(bit[i] == 2)x.pb(a[i].y);
            }
            sort(all(x));
            sort(all(y));
            int ans = 0;
            for(int i=0;i<n;i++)
            {
                int xx,yy;
                auto ix = lower_bound(all(x),a[i].y) - x.begin();
                auto iy = lower_bound(all(y),a[i].x) - y.begin();

                if(ix == 0)xx = abs(x[ix] - a[i].y);
                else if(ix == x.size())xx = abs(x.back() - a[i].y);
                else xx = min(abs(x[ix]-a[i].y), abs(x[ix-1]-a[i].y));

                if(iy == 0)yy = abs(y[iy] - a[i].x);
                else if(iy == y.size())yy = abs(y.back() - a[i].x);
                else yy = min(abs(y[iy]-a[i].x), abs(y[iy-1]-a[i].x));

                ans += min(xx,yy)*a[i].p;
            }
            val[cnt] = min(val[cnt],ans);
        }
        for(int i=0;i<=n;i++)cout<<val[i]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: reference to 'data' is ambiguous
   33 |         data a[n];
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:19:8: note:                 'struct data'
   19 | struct data
      |        ^~~~
a.cc:35:34: error: 'a' was not declared in this scope
   35 |         for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y>>a[i].p,tot *= 3LL;
      |                                  ^
a.cc:50:37: error: 'a' was not declared in this scope
   50 |                 if(bit[i] == 1)y.pb(a[i].x);
      |                                     ^
a.cc:51:37: error: 'a' was not declared in this scope
   51 |                 if(bit[i] == 2)x.pb(a[i].y);
      |                                     ^
a.cc:59:46: error: 'a' was not declared in this scope
   59 |                 auto ix = lower_bound(all(x),a[i].y) - x.begin();
      |                                              ^