結果
| 問題 |
No.2366 登校
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-05-02 00:42:24 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,676 bytes |
| コンパイル時間 | 4,860 ms |
| コンパイル使用メモリ | 166,912 KB |
| 実行使用メモリ | 817,920 KB |
| 最終ジャッジ日時 | 2024-11-22 09:29:44 |
| 合計ジャッジ時間 | 28,787 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 1 TLE * 1 MLE * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define dbg puts("dbg");
#define outp(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(), (x).end()
#define test int t; cin >> t; while(t--){solve();}
#define MOD 998244353
int fpb(int a,int b){if(b == 0){return a;}return fpb(b, a%b);}
int kpk(int a,int b){return (a*b)/fpb(a, b);}
int n, m, k, t;
map <int, int> dp[82][82];
vector <pair <int, pair <int, pii>>> v;
int f(int baris, int kolom, int curWaktu){
if(curWaktu > t) return 2e18;
if(baris == n && kolom == m) return 0;
if(dp[baris][kolom].count(curWaktu)) return dp[baris][kolom][curWaktu];
int pilihan1 = f(n, m, curWaktu+n+m-baris-kolom);
int mini = pilihan1;
if(curWaktu+n+m-baris-kolom <= t){
mini = pilihan1;
} else {
int pilihan2;
for(auto i : v){
int barisNext = i.first, kolomNext = i.second.first;
int waktuMundur = i.second.second.first, lelah = i.second.second.second;
pilihan2 = f(barisNext, kolomNext, curWaktu+barisNext+kolomNext-baris-kolom+1-waktuMundur)+lelah;
mini = min(mini, pilihan2);
}
}
dp[baris][kolom][curWaktu] = mini;
return mini;
}
void solve(){
cin >> n >> m >> k >> t;
while(k--){
int a, b, c, d; cin >> a >> b >> c >> d;
v.pb({a, {b, {c, d}}});
}
int res = f(1, 1, 0);
cout << ((res != 2e18)?res:-1) << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
solve();
return 0;
}
vjudge1