# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503383 | 2022-01-07T18:52:04 Z | Stickfish | Present (RMI21_present) | C++17 | 4000 ms | 296 KB |
#include <iostream> #include <vector> #include <bitset> #include <algorithm> using namespace std; using ll = long long; const int MAXN = 1000; ll gcd(ll a, ll b) { if (!b) return a; return gcd(b, a % b); } ll divcnt[MAXN]; ll isgcdcnt[MAXN]; bitset<MAXN> bs; bool recur(ll& k, vector<ll>& v) { int n = v.size(); int t0 = v[0]; for (int i = 1; i <= t0; ++i) { divcnt[i] = isgcdcnt[i] = bs[i] = 0; } for (auto t : v) bs[t] = 1; bool isok = true; for (int t = t0; t >= 1; --t) { for (int ti = t; ti <= t0; ti += t) { //if (ti % t == 0) { divcnt[t] += bs[ti]; isgcdcnt[t] -= isgcdcnt[ti]; //} } isgcdcnt[t] += divcnt[t] * (divcnt[t] - 1); if (!bs[t] && isgcdcnt[t] > 0) { isok = false; break; } } if (isok) { if (!k) return true; --k; } int x = v.back(); for (int t = 1; t < x; ++t) { v.push_back(t); if (recur(k, v)) return true; v.pop_back(); } return false; } void solve() { ll k; cin >> k; if (k == 0) { cout << 0 << endl; return; } --k; vector<ll> ans; for (int t = 1;; ++t) { ans.push_back(t); if (recur(k, ans)) { break; } ans.pop_back(); } cout << ans.size() << ' '; reverse(ans.begin(), ans.end()); for (auto x : ans) cout << x << ' '; cout << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; while (t--) { solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Execution timed out | 4018 ms | 296 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Execution timed out | 4018 ms | 296 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Execution timed out | 4018 ms | 296 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Execution timed out | 4018 ms | 296 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |