Submission #1211904

#TimeUsernameProblemLanguageResultExecution timeMemory
1211904countlessDetecting Molecules (IOI16_molecules)C++20
19 / 100
0 ms328 KiB
#include "molecules.h" #include <cstdint> #include <random> #include <bitset> #include <vector> #include <iostream> #include <cassert> // #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll MOD = 998244353; const ll INF = 1e18; const ld EPS = 1e-12; #define endl "\n" #define sp <<" "<< #define REP(i, a, b) for(ll i = a; i < b; i++) #define dbg(x) cout << #x << " = " << x << endl #define mp make_pair #define pb push_back #define fi first #define se second #define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) const int MAXN = 1e3+5; bitset<MAXN> dp; vector<int> find_subset(int l, int r, vector<int> w) { assert(l <= 5e5 and r <= 5e5); int n = w.size(); dp[0] = 1; for (int i = 0; i < n; i++) { dp |= (dp << w[i]); } int diff = MAXN - r - 1; dp <<= diff, dp >>= diff; dp >>= l; int o = dp._Find_first(); int x = l + o; vector<int> kp(x+1, 0), pr(x+1, -1); kp[0] = 1; REP(i, 0, n) { for (int j = x - w[i]; j >= 0; j--) { if (kp[j] and !kp[j + w[i]]) { kp[j + w[i]] = true; pr[j + w[i]] = i; } } } vector<int> ans; while (x and pr[x] != -1) { ans.push_back(pr[x]); x -= w[pr[x]]; } return ans; }

Compilation message (stderr)

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
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...