Submission #715340

# Submission time Handle Problem Language Result Execution time Memory
715340 2023-03-26T14:22:44 Z aykhn Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) \
                    cout << v[i] << " "; \
                    cout<<endl;

int[] find_subset(int l, int u, int[] w)
{
    int n = sizeof(w) / sizeof(w[0]);

    int l = 0;
    int r = 0;

    sort(w, w+n);

    while (r < n)
    {
        sum += w[r];

        while (sum > u)
        {
            sum -= w[l];
            l++;
        }

        if (sum >= l)
        {
            int ans[r - l + 1];
            int k = 0;
            for (int i = l; i <= r; i++, k++)
            {
                ans[k] = i;
            }

            return ans;
        }

        r++;
    }

    int ans[0];

    return ans;
}

Compilation message

molecules.cpp:26:4: error: structured binding declaration cannot have type 'int'
   26 | int[] find_subset(int l, int u, int[] w)
      |    ^~
molecules.cpp:26:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:26:4: error: empty structured binding declaration
molecules.cpp:26:7: error: expected initializer before 'find_subset'
   26 | int[] find_subset(int l, int u, int[] w)
      |       ^~~~~~~~~~~