제출 #1309859

#제출 시각아이디문제언어결과실행 시간메모리
1309859shirokitoDetecting Molecules (IOI16_molecules)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() using ll = long long; const int N = 5e5 + 5; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); pair<int, int> v[N]; namespace sub5 { bool check(int n, int l, int u) { return (n <= 10000 && u <= 500000); } bitset<N> dp; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); dp[0] = 1; for (int &x: w) { dp |= (dp << x); } int cand_weight = -1; for (int x = l; x <= u; x++) { if (dp[x] == 1) { cand_weight = x; break; } } if (cand_weight == -1) { return vector<int> {}; } vector<pair<int, int>> v; for (int i = 0; i < n; i++) { v.push_back({w[i], i}); } for (int _ = 0; _ <= 100; _++) { shuffle(all(v), rng); vector<int> ans; int cur = cand_weight; for (int i = 0; i < n; i++) { if (cur - v[i].first >= 0 && dp[cur - v[i].first]) { ans.push_back(v[i].second); cur -= v[i].first; } } if (cur == 0) return ans; } return vector<int> {}; } } namespace sub6 { pair<int, int> v[N]; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); for (int i = 0; i < n; i++) { v[i] = {w[i], i}; } sort(v, v + n); if (v[0].first >= l && v[0].first <= u) { return vector<int> {0}; } if (v[n - 1].first >= l && v[n - 1].first <= u) { return vector<int> {n - 1}; } if (v[0].first > u) { return vector<int> {}; } for (int _ = 0; _ <= 1000; _++) { vector<int> ans; ll cur = 0; for (int i = 0; i < n; i++) { if (cur + v[i].first > u) { continue; } cur += v[i].first; ans.push_back(v[i].second); if (cur >= l && cur <= u) { return ans; } } int B = rand(1, 100); for (int L = 0; L < n; L += B) { int R = min(n - 1, L + B - 1); shuffle(v + L, v + R + 1, rng); } } return vector<int> {}; } }; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); if (sub5::check(n, l, u)) return sub5::find_subset(l, u, w); return sub6::find_subset(l, u, w); } #ifdef LOCAL void solve() { int n, l, u; cin >> n >> l >> u; vector<int> w(n); for (int &x: w) cin >> x; auto ans = find_subset(l, u, w); for (int x: ans) cout << x << ' '; cout << '\n'; } signed main() { cin.tie(0) -> sync_with_stdio(0); int T = 1; // cin >> T; while (T--) { solve(); } } #endif

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

molecules.cpp: In function 'std::vector<int> sub6::find_subset(int, int, std::vector<int>)':
molecules.cpp:112:25: error: too many arguments to function 'int rand()'
  112 |             int B = rand(1, 100);
      |                     ~~~~^~~~~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from molecules.cpp:1:
/usr/include/stdlib.h:573:12: note: declared here
  573 | extern int rand (void) __THROW;
      |            ^~~~
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
      |         ^~~~