結果
問題 |
No.1192 半部分列
|
ユーザー |
![]() |
提出日時 | 2020-08-22 16:24:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 887 bytes |
コンパイル時間 | 3,422 ms |
コンパイル使用メモリ | 250,708 KB |
最終ジャッジ日時 | 2025-01-13 10:10:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 5 TLE * 12 |
ソースコード
#include <bits/extc++.h> #ifndef DUMP #define DUMP(...) (void)0 #endif using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); string s, t; cin >> s >> t; int n = size(s), m = size(t); vector<int> p(n + 1); p[n] = m; for (int i = n; i--;) { p[i] = p[i + 1] - 1; while (p[i] >= 0 and t[p[i]] != s[i]) --p[i]; } if (p[0] >= 0) { cout << "-1\n"; exit(0); } vector<array<int, 26>> nxt(n + 1); nxt[n].fill(n); for (int i = n; i--;) { nxt[i] = nxt[i + 1]; nxt[i][s[i] - 'a'] = i; } string res; int i = 0, j = 0; while (true) { for (char c = 'a'; c <= 'z'; ++c) { if (p[nxt[i][c - 'a']] >= j) continue; res += c; i = nxt[i][c - 'a'] + 1; while (j < m and t[j] != c) ++j; break; } if (j == m) break; } cout << res << '\n'; }