Submission #60321077
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define int long longunordered_map<string, vector<vector<int>>> memo;vector<vector<int>> solve(int n, int m, int size, int last) {if (size == n) {return {{}};}string key = to_string(size) + "," + to_string(last);if (memo.count(key)) {return memo[key];}vector<vector<int>> result;
#include <bits/stdc++.h> using namespace std; #define int long long unordered_map<string, vector<vector<int>>> memo; vector<vector<int>> solve(int n, int m, int size, int last) { if (size == n) { return {{}}; } string key = to_string(size) + "," + to_string(last); if (memo.count(key)) { return memo[key]; } vector<vector<int>> result; for (int next = last + 10; next <= m; ++next) { auto sub_sequences = solve(n, m, size + 1, next); for (auto& sub_seq : sub_sequences) { sub_seq.insert(sub_seq.begin(), next); result.push_back(sub_seq); } } memo[key] = result; return result; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector<vector<int>> ans; for (int start = 1; start <= m; ++start) { auto sequences = solve(n, m, 1, start); for (auto& seq : sequences) { seq.insert(seq.begin(), start); ans.push_back(seq); } } cout << ans.size() << '\n'; for (const auto& seq : ans) { for (auto& u : seq) { cout << u << ' '; } cout << '\n'; } }
Submission Info
Submission Time | |
---|---|
Task | D - Keep Distance |
User | benzyl |
Language | C++ 20 (gcc 12.2) |
Score | 425 |
Code Size | 1285 Byte |
Status | AC |
Exec Time | 358 ms |
Memory | 135384 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 425 / 425 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt |
All | sample00.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 3452 KB |
testcase00.txt | AC | 1 ms | 3520 KB |
testcase01.txt | AC | 1 ms | 3644 KB |
testcase02.txt | AC | 1 ms | 3456 KB |
testcase03.txt | AC | 1 ms | 3464 KB |
testcase04.txt | AC | 1 ms | 3604 KB |
testcase05.txt | AC | 1 ms | 3520 KB |
testcase06.txt | AC | 1 ms | 3624 KB |
testcase07.txt | AC | 2 ms | 3776 KB |
testcase08.txt | AC | 2 ms | 3756 KB |
testcase09.txt | AC | 1 ms | 3396 KB |
testcase10.txt | AC | 2 ms | 3656 KB |
testcase11.txt | AC | 1 ms | 3476 KB |
testcase12.txt | AC | 2 ms | 3628 KB |
testcase13.txt | AC | 4 ms | 4528 KB |
testcase14.txt | AC | 3 ms | 4344 KB |
testcase15.txt | AC | 2 ms | 3636 KB |
testcase16.txt | AC | 2 ms | 3464 KB |
testcase17.txt | AC | 18 ms | 10536 KB |
testcase18.txt | AC | 14 ms | 8716 KB |
testcase19.txt | AC | 74 ms | 34320 KB |
testcase20.txt | AC | 3 ms | 3512 KB |
testcase21.txt | AC | 2 ms | 3604 KB |
testcase22.txt | AC | 3 ms | 3740 KB |
testcase23.txt | AC | 3 ms | 3908 KB |
testcase24.txt | AC | 5 ms | 4840 KB |
testcase25.txt | AC | 9 ms | 6952 KB |
testcase26.txt | AC | 22 ms | 12860 KB |
testcase27.txt | AC | 55 ms | 27356 KB |
testcase28.txt | AC | 140 ms | 60384 KB |
testcase29.txt | AC | 358 ms | 135384 KB |