結果
問題 |
No.1862 Copy and Paste
|
ユーザー |
|
提出日時 | 2022-03-04 22:14:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,016 bytes |
コンパイル時間 | 2,054 ms |
コンパイル使用メモリ | 205,724 KB |
最終ジャッジ日時 | 2025-01-28 05:26:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 TLE * 3 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; const ll C = numeric_limits<int>::max(); inline ll f(int s, int t){ return s * C + t; } int main(){ cin.tie(0); ios::sync_with_stdio(0); using ll = long long; ll A,B,N; cin >> A >> B >> N; using P = pair<ll,ll>; priority_queue<P,vector<P>,greater<P>> q; q.push({0LL, f(1, 0)}); unordered_map<ll,ll> mp; mp[f(1, 0)] = 0; while(!q.empty()) { auto [dist, p] = q.top(); q.pop(); int s = (int)(p / C), t = p % C; if(dist != mp[f(s, t)]) continue; if(s >= N) { cout << dist << endl; return 0; } if(!mp.count(f(s, s)) || mp[f(s, s)] > dist + A) { mp[f(s, s)] = dist + A; q.push({dist + A, f(s, s)}); } if(!mp.count(f(s + t, t)) || mp[f(s + t, t)] > dist + B) { mp[f(s + t, t)] = dist + B; q.push({dist + B, f(s + t, t)}); } } }