제출 #1323467

#제출 시각아이디문제언어결과실행 시간메모리
1323467chandan_159Detecting Molecules (IOI16_molecules)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // ====== Short types ====== #define ll long long #define ld long double #define str string #define pll pair<ll, ll> #define pii pair<int, int> #define vll vector<ll> #define vii vector<int> #define vld vector<ld> #define vs vector<string> #define vch vector<char> #define vpll vector<pll> #define vpii vector<pii> #define vvll vector<vll> #define mll map<ll, ll> #define msl map<string, ll> #define mcl map<char, ll> #define sll set<ll> #define scl set<char> #define ssl set<string> #define mull multiset<ll> #define mupll multiset<pll> #define pqmax priority_queue<ll> // max heap #define pqmin priority_queue<ll, vector<ll>, greater<ll>> // min heap #define pqmaxpll priority_queue<pll> // max heap of pairs #define pqminpll priority_queue<pll, vector<pll>, greater<pll>> // min heap of pairs // ====== Queues ====== #define qll queue<ll> #define qpll queue<pll> // ====== Common macros ====== #define pb push_back #define ph push #define fr front #define pp pop() #define tp top #define ppb pop_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)((x).size()) #define mpr make_pair #define bk back #define rtn return #define ctn continue #define brk break // ====== Algorithms ====== #define uniq(x) x.erase(unique(all(x)), x.end()) // works only after sorting #define sortv(v) sort(all(v)) #define rsortv(v) sort(rall(v)) #define maxv(v) *max_element(all(v)) #define minv(v) *min_element(all(v)) #define sumv(v) accumulate(all(v), 0LL) #define rev(v) reverse(all(v)) #define lb lower_bound #define ub upper_bound // ====== Loops ====== #define forr(i, n) for (ll i = 0; i < (n); i++) #define rforr(i, n) for (ll i = (n)-1; i >= 0; i--) #define forab(i, a, b) for (ll i = (a); i <= (b); i++) #define forba(i, a, b) for (ll i = (a); i >= (b); i--) // ====== Input Shortcuts ====== #define cn(n) ll n; cin >> n; #define cna(a, b) ll a, b; cin >> a >> b; #define cna3(a, b, c) ll a, b, c; cin >> a >> b >> c; #define cna4(a, b, c, d) ll a, b, c, d; cin >> a >> b >> c >> d; // ====== String Shortcuts ====== #define cs(s) string s; cin >> s; #define csa(a, b) string a, b; cin >> a >> b; #define csa3(a, b, c) string a, b, c; cin >> a >> b >> c; #define csa4(a, b, c, d) string a, b, c, d; cin >> a >> b >> c >> d; // ====== IO helpers ====== #define fastio ios::sync_with_stdio(false); cin.tie(nullptr); #define nl '\n' #define ct cout #define YES ct << "YES\n" #define NO ct << "NO\n" #define Yes ct << "Yes\n" #define No ct << "No\n" #define YN(x) ct << ((x) ? "YES\n" : "NO\n") #define yn(x) ct << ((x) ? "Yes\n" : "No\n") // ====== Debugging ====== #define debug(x) cerr << #x << " = " << (x) << '\n' #define debugv(v) cerr << #v << ": "; for (auto _x : v) cerr << _x << " "; cerr << '\n' // ====== Miscellaneous ====== #define ins insert #define ers erase #define cntv count #define fnd find #define bg begin #define ed end // ====== Constants ====== const ll INF = 1e18; const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll N = 1e6 + 5; const ld EPS = 1e-9; const ld PI = acos(-1.0); const ll ngmx = -1e18; // ====== Input/Output Helpers ====== template<typename T> void cinv(vector<T> &v, ll n) { v.resize(n); forr(i, n) cin >> v[i]; } template<typename T> void cinvv(vector<vector<T>> &v, ll n, ll m) { v.assign(n, vector<T>(m)); forr(i, n) forr(j, m) cin >> v[i][j]; } template<typename T> void ctv(const vector<T> &v, char sep = ' ') { for (auto &x : v) ct << x << sep; ct << '\n'; } template<typename T> void ctvv(const vector<vector<T>> &v) { for (auto &row : v) ctv(row); } // ====== DSU ======= class DSU { private: vector<int> parents; vector<int> sizes; public: DSU(int size) : parents(size), sizes(size, 1) { for (int i = 0; i < size; i++) { parents[i] = i; } } /** @return the "representative" node in x's component */ int find(int x) { return parents[x] == x ? x : (parents[x] = find(parents[x])); } /** @return whether the merge changed connectivity */ bool unite(int x, int y) { int x_root = find(x); int y_root = find(y); if (x_root == y_root) { return false; } if (sizes[x_root] < sizes[y_root]) { swap(x_root, y_root); } sizes[x_root] += sizes[y_root]; parents[y_root] = x_root; return true; } /** @return whether x and y are in the same connected component */ bool connected(int x, int y) { return find(x) == find(y); } // to use find + unite . }; // ====== Math Helpers ====== /* GCD + LCM*/ ll gcdll(ll a, ll b) { return b==0 ? a : gcdll(b, a%b); } ll lcmll(ll a, ll b) { ll lmx = 1e18; if(a==0 || b==0) return 0; ll g = gcdll(a,b); if (a / g > lmx / b) return lmx; return (a / g) * b; } #define powmod bigmod ll bigmod(ll a, ll b, ll m = MOD) { ll r = 1; a %= m; while (b) { if (b & 1) r = (r * a) % m; a = (a * a) % m; b >>= 1; } return r; } ll addmod(ll a, ll b, ll m = MOD) { a += b; if (a >= m) a -= m; return a; } ll submod(ll a, ll b, ll m = MOD) { a -= b; if (a < 0) a += m; return a; } ll mulmod(ll a, ll b, ll m = MOD) { return (a * 1LL * b) % m; } ll invmod(ll a, ll m = MOD) { return bigmod(a, m - 2, m); } // Fermat’s inverse (for prime mod) // ====== Prime & Sieve ====== vector<ll> primes; vector<bool> isprime(N, true); void sieve(ll n = N - 1) { isprime[0] = isprime[1] = false; for (ll i = 2; i * i <= n; i++) if (isprime[i]) for (ll j = i * i; j <= n; j += i) isprime[j] = false; for (ll i = 2; i <= n; i++) if (isprime[i]) primes.pb(i); } bool isPrime(ll n) { if (n < 2) return false; for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } // ====== Combinations ====== vll fact(N), invfact(N); void init_fact(ll n = N - 1) { fact[0] = 1; forab(i, 1, n) fact[i] = (fact[i - 1] * i) % MOD; invfact[n] = invmod(fact[n]); forba(i, n - 1, 0) invfact[i] = (invfact[i + 1] * (i + 1)) % MOD; } ll nCr(ll n, ll r) { if (r < 0 || r > n) return 0; return (((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD; } // // Precompute primes and factorials // sieve(); // init_fact(); // ====== Bit Helpers ====== #define bitcount(x) __builtin_popcountll(x) #define clz(x) __builtin_clzll(x) #define ctz(x) __builtin_ctzll(x) int[] find_subset(int u, int v, int[] w){ ll n = sz(w); vpll a(n); forr(i , n){ a[i] = {w[i] , i}; } sortv(a); ll l = 0; ll sum = 0; vll ans; forr(r , n){ sum += a[r].ff; while(sum > v && l <= r){ sum -= a[l].ff; l++; } if(sum <= v && u <= sum) { while(l <= r){ ans.pb(a[l].ss); l ++; } return ans; } } return ans; }

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

molecules.cpp:229:4: error: structured binding declaration cannot have type 'int'
  229 | int[] find_subset(int u, int v, int[] w){
      |    ^~
molecules.cpp:229:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:229:4: error: empty structured binding declaration
molecules.cpp:229:7: error: expected initializer before 'find_subset'
  229 | int[] find_subset(int u, int v, int[] w){
      |       ^~~~~~~~~~~
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~