Submission #3772210
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 2000; const int K = 10000; string s[N]; bitset<K + 1> bs[N + 1]; int nv[2]; pair<int, int> v[2][N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> s[i]; } bs[n].set(k); for (int i = n - 1; i >= 0; --i) { int sz = (int) s[i].size(); bs[i] = bs[i + 1] | (bs[i + 1] >> sz); if (bs[i + 1][sz]) { v[0][nv[0]++] = make_pair(i, 0); } } string ans = ""; for (int i = 0; i < k; ++i) { int iter = i & 1; char c = 'z'; for (int j = 0; j < nv[iter]; ++j) { const auto& p = v[iter][j]; c = min(c, s[p.first][p.second]); } ans += c; int bid = n; for (int it = 0; it < nv[iter]; ++it) { int id, j; tie(id, j) = v[iter][it]; if (s[id][j] != c) { continue; } if (j == (int) s[id].size() - 1) { bid = min(bid, id); } else { v[iter ^ 1][nv[iter ^ 1]++] = make_pair(id, j + 1); } } for (int j = bid + 1; j < n; ++j) { if (i + 1 + (int) s[j].size() <= k && bs[j + 1][i + 1 + (int) s[j].size()]) { v[iter ^ 1][nv[iter ^ 1]++] = make_pair(j, 0); } } nv[iter] = 0; } cout << ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Iroha Loves Strings |
User | nthoang |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1363 Byte |
Status | RE |
Exec Time | 103 ms |
Memory | 3840 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_sample01, 0_sample02, 0_sample03 |
All | 0_sample01, 0_sample02, 0_sample03, abab0, abten0, allsame0, allsame_ex0, bigrand0, bigrand1, firstlast0, firstlast1, fullrand0, fullrand1, fullrand2, kaidan0, maxrand0, maxrand1, maxrand2, roll_hyper0, roll_hyper1, roll_hyper_r0, rolling0, rolling1, smallc0, smallc1, smallrand0, smallrand1, smallrand2, zzza0 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_sample01 | AC | 1 ms | 256 KB |
0_sample02 | AC | 1 ms | 256 KB |
0_sample03 | AC | 1 ms | 256 KB |
abab0 | WA | 4 ms | 2560 KB |
abten0 | AC | 5 ms | 3328 KB |
allsame0 | RE | 103 ms | 3200 KB |
allsame_ex0 | RE | 103 ms | 3072 KB |
bigrand0 | AC | 4 ms | 2304 KB |
bigrand1 | AC | 4 ms | 2944 KB |
firstlast0 | AC | 5 ms | 3328 KB |
firstlast1 | AC | 5 ms | 3328 KB |
fullrand0 | AC | 5 ms | 3328 KB |
fullrand1 | AC | 5 ms | 3328 KB |
fullrand2 | AC | 5 ms | 3328 KB |
kaidan0 | WA | 5 ms | 3328 KB |
maxrand0 | AC | 5 ms | 3200 KB |
maxrand1 | AC | 4 ms | 3200 KB |
maxrand2 | AC | 5 ms | 3200 KB |
roll_hyper0 | AC | 6 ms | 3840 KB |
roll_hyper1 | AC | 6 ms | 3840 KB |
roll_hyper_r0 | AC | 6 ms | 3840 KB |
rolling0 | AC | 6 ms | 3840 KB |
rolling1 | AC | 6 ms | 3840 KB |
smallc0 | WA | 5 ms | 3072 KB |
smallc1 | RE | 103 ms | 3072 KB |
smallrand0 | AC | 1 ms | 256 KB |
smallrand1 | AC | 1 ms | 256 KB |
smallrand2 | AC | 1 ms | 256 KB |
zzza0 | AC | 5 ms | 2688 KB |