Submission #8899278
Source Code Expand
#include <bits/stdc++.h> #define ls (o << 1) #define rs (o << 1 | 1) #define mid ((L + R) >> 1) using namespace std; typedef long long LL; const int N = 200500; const int mod = 1e9 + 7; char s[N]; int suf[N][26], dp[N]; int n; int main() { #ifdef TEST freopen("input.txt", "r", stdin); #endif scanf("%s", s); n = strlen(s); for (int i = 0; i < 26; ++i) { suf[n][i] = n; } for (int i = n - 1; i >= 0; --i) { dp[i] = n + 5; for (int j = 0; j < 26; ++j) { suf[i][j] = suf[i + 1][j]; dp[i] = min(dp[i], dp[suf[i][j]] + 1); } suf[i][s[i] - 'a'] = i; } int now = 0; while (*max_element(suf[now], suf[now] + 26) != n) { int nxt = suf[now][0]; for (int i = 1; i < 26; ++i) { if (dp[suf[now][i]] < dp[nxt]) { nxt = suf[now][i]; } } printf("%c", s[nxt]); now = nxt + 1; } printf("%c", max_element(suf[now], suf[now] + 26) - suf[now] + 'a'); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Don't Be a Subsequence |
User | kp600168 |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 933 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 21504 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:40:68: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] printf("%c", max_element(suf[now], suf[now] + 26) - suf[now] + 'a'); ^ ./Main.cpp:16:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", s); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 1 ms | 256 KB |
10.txt | AC | 14 ms | 21504 KB |
11.txt | AC | 14 ms | 21504 KB |
12.txt | AC | 14 ms | 21376 KB |
13.txt | AC | 14 ms | 21504 KB |
14.txt | AC | 14 ms | 21504 KB |
15.txt | AC | 14 ms | 21504 KB |
16.txt | AC | 14 ms | 21504 KB |
17.txt | AC | 14 ms | 21504 KB |
18.txt | AC | 14 ms | 21504 KB |
19.txt | AC | 14 ms | 21504 KB |
2.txt | AC | 1 ms | 384 KB |
20.txt | AC | 14 ms | 21504 KB |
21.txt | AC | 14 ms | 21504 KB |
22.txt | AC | 14 ms | 21504 KB |
23.txt | AC | 14 ms | 21504 KB |
24.txt | AC | 13 ms | 21504 KB |
25.txt | AC | 13 ms | 21504 KB |
26.txt | AC | 13 ms | 21504 KB |
27.txt | AC | 13 ms | 21504 KB |
28.txt | AC | 13 ms | 21504 KB |
29.txt | AC | 13 ms | 21504 KB |
3.txt | AC | 2 ms | 1280 KB |
30.txt | AC | 13 ms | 21504 KB |
4.txt | AC | 2 ms | 1280 KB |
5.txt | AC | 8 ms | 12288 KB |
6.txt | AC | 8 ms | 12288 KB |
7.txt | AC | 14 ms | 21504 KB |
8.txt | AC | 14 ms | 21504 KB |
9.txt | AC | 14 ms | 21504 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |