Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define pb emplace_back
- using namespace std;
- using ll = long long;
- const int maxn = 2010;
- map<int, map<int, int>> dp[maxn];
- map<int, map<int, bool>> did[maxn];
- struct info {
- int a, b, c;
- bool operator < (const info &x) const{
- return a > x.a;
- }
- };
- int res[maxn];
- bool out[maxn];
- void bf() {
- ofstream fout("pA.out");
- priority_queue<info> togo;
- //queue<info> togo;
- fill(res, res+maxn, maxn+1);
- dp[1][1][0] = 1;
- togo.push({1,1,0});
- while (!togo.empty()) {
- auto [a, b, c] = togo.top();
- // if (!out[a-1]) {
- // cerr << a-1 << " : " << res[a-1] << '\n';
- // out[a-1] = true;
- // fout << res[a-1] << ", ";
- // }
- togo.pop();
- int val = dp[a][b][c];
- //cerr << a << ' ' << b << ' ' << c << ' ' << " : " << val << '\n';
- auto update = [&](int a, int b, int c, int cost) {
- if (a > 2000) return;
- if (b > c) swap(b, c);
- if (!dp[a][b].count(c))
- togo.push({a, b, c});
- if (!dp[a][b].count(c) || dp[a][b][c] > cost)
- dp[a][b][c] = cost;
- };
- update(a+b, b, c, val+1);
- update(a+c, b, c, val+1);
- update(a, a, c, val+1);
- update(a, b, a, val+1);
- res[a] = min(res[a], val);
- }
- for (int i = 1;i <= 2000;++i)
- cout << res[i] << ",\n", fout << res[i] << ",\n";
- }
- signed main(){
- ios_base::sync_with_stdio(0), cin.tie(0);
- bf();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement