Submission #2872174
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n,rec[N][26],las[N][26],sta[26],cur[26]; char s[N]; void solve(int p) { if (p > n) return; for (int i = 0 ; i < 26 ; ++ i) { if (!las[p][i]) { cout << (char)(i + 'a'); solve(rec[p][i]); return; } } } int main() { scanf("%s",s+1); n = strlen(s+1); for (int i = 0 ; i < 26 ; ++ i) sta[i] = n + 1; for (int i = n ; i >= 0 ; -- i) { for (int j = 0 ; j < 26 ; ++ j) las[i][j] = cur[j], rec[i][j] = sta[j]; if (!i) break; cur[s[i] - 'a'] = i; sta[s[i] - 'a'] = i; int key = 1; for (int i = 0 ; i < 26 ; ++ i) key &= (cur[i] > 0); if (key) memset(cur,0,sizeof cur); } solve(0); cout << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Don't Be a Subsequence |
User | cly_none |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 796 Byte |
Status | AC |
Exec Time | 22 ms |
Memory | 41472 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",s+1); ^
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 | 2 ms | 2304 KB |
10.txt | AC | 21 ms | 41216 KB |
11.txt | AC | 21 ms | 41216 KB |
12.txt | AC | 21 ms | 41088 KB |
13.txt | AC | 21 ms | 41216 KB |
14.txt | AC | 21 ms | 41216 KB |
15.txt | AC | 21 ms | 41216 KB |
16.txt | AC | 21 ms | 41216 KB |
17.txt | AC | 21 ms | 41216 KB |
18.txt | AC | 22 ms | 41216 KB |
19.txt | AC | 22 ms | 41344 KB |
2.txt | AC | 3 ms | 2432 KB |
20.txt | AC | 22 ms | 41344 KB |
21.txt | AC | 22 ms | 41472 KB |
22.txt | AC | 22 ms | 41472 KB |
23.txt | AC | 22 ms | 41472 KB |
24.txt | AC | 21 ms | 41088 KB |
25.txt | AC | 21 ms | 41088 KB |
26.txt | AC | 21 ms | 41088 KB |
27.txt | AC | 21 ms | 41088 KB |
28.txt | AC | 21 ms | 41088 KB |
29.txt | AC | 21 ms | 41088 KB |
3.txt | AC | 3 ms | 3328 KB |
30.txt | AC | 21 ms | 41088 KB |
4.txt | AC | 3 ms | 3328 KB |
5.txt | AC | 12 ms | 22656 KB |
6.txt | AC | 11 ms | 22784 KB |
7.txt | AC | 21 ms | 41216 KB |
8.txt | AC | 21 ms | 41216 KB |
9.txt | AC | 21 ms | 41088 KB |
sample1.txt | AC | 2 ms | 2304 KB |
sample2.txt | AC | 2 ms | 2304 KB |
sample3.txt | AC | 2 ms | 2304 KB |