結果
| 問題 | No.3427 Erasing a Subsequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-23 08:53:08 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 12 ms / 2,000 ms |
| + 271µs | |
| コード長 | 736 bytes |
| 記録 | |
| コンパイル時間 | 1,387 ms |
| コンパイル使用メモリ | 222,408 KB |
| 実行使用メモリ | 9,864 KB |
| 最終ジャッジ日時 | 2026-10-23 08:53:19 |
| 合計ジャッジ時間 | 3,153 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M; cin >> N >> M;
vector<int> S(N),T(M);
for(auto &s : S) cin >> s;
for(auto &t : T) cin >> t;
T.push_back(-2);
vector<vector<int>> dp(M+1,{1001001001});
dp.at(0) = {};
for(auto s : S){
vector<int> hold = {-1};
for(int i=0; i<=M; i++){
vector<int> next = {-1};
if(s == T.at(i)) next = dp.at(i);
dp.at(i).push_back(s);
if(hold.size() == 0 || hold.at(0) != -1) dp.at(i) = min(dp.at(i),hold);
swap(hold,next);
}
}
for(auto &d : dp.at(M)) cout << d << " "; cout << endl;
}