Submission #1982071
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <bitset> using namespace std; typedef long long ll; typedef pair<string,int> P; typedef pair<P,P> P2; const ll INF=100000000000000001; int t[26][200001]={}; int ls; int reg(int pos1,int t2){ int ub=ls,lb=pos1; int k=t[t2][pos1]; if(t[t2][ub]==k)return pos1; while(ub-lb>1){ int mid=(ub+lb)/2; if(t[t2][mid]>k){ ub=mid; }else{ lb=mid; } } return ub; } int main() { string s; cin>>s; ls=s.length(); for(int i=1;i<ls+1;++i){ int k=(int)s[i-1]-97; for(int j=0;j<26;++j)t[j][i]=t[j][i-1]; // cout<<k<<endl;; t[k][i]++; } // cout<<"here"; queue<P> que; for(int i=0;i<26;++i){ string chr="a"; chr[0]=((char)(97+i)); que.push(P(chr,0)); } while(!que.empty()){ P p1=que.front();que.pop(); string s1=p1.first; int pos=p1.second; int ls1=s1.length(); int t1=(int)s1[ls1-1]-97; int pos2=reg(pos,t1); if(pos2==pos){ cout<<s1<<endl; return 0; }else{ for(int i=0;i<26;++i){ char chr=(char)(97+i); string s2=s1+chr; que.push(P(s2,pos2)); } } // cout<<s1<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Don't Be a Subsequence |
User | fgtohru |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1209 Byte |
Status | TLE |
Exec Time | 2170 ms |
Memory | 1040312 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 4 ms | 16768 KB |
10.txt | TLE | 2164 ms | 1008012 KB |
11.txt | TLE | 2163 ms | 1007060 KB |
12.txt | TLE | 2163 ms | 1009112 KB |
13.txt | TLE | 2163 ms | 1009368 KB |
14.txt | TLE | 2165 ms | 1008464 KB |
15.txt | TLE | 2166 ms | 1006392 KB |
16.txt | TLE | 2167 ms | 1010184 KB |
17.txt | TLE | 2169 ms | 998340 KB |
18.txt | TLE | 2167 ms | 1010504 KB |
19.txt | TLE | 2164 ms | 1012324 KB |
2.txt | TLE | 2165 ms | 1040312 KB |
20.txt | TLE | 2164 ms | 1011656 KB |
21.txt | TLE | 2164 ms | 1014388 KB |
22.txt | TLE | 2166 ms | 1014344 KB |
23.txt | TLE | 2165 ms | 1010636 KB |
24.txt | TLE | 2163 ms | 1007828 KB |
25.txt | TLE | 2164 ms | 999764 KB |
26.txt | TLE | 2163 ms | 1003476 KB |
27.txt | TLE | 2166 ms | 1006036 KB |
28.txt | TLE | 2166 ms | 1004756 KB |
29.txt | TLE | 2170 ms | 1004540 KB |
3.txt | TLE | 2164 ms | 1024428 KB |
30.txt | TLE | 2168 ms | 1002708 KB |
4.txt | TLE | 2164 ms | 1027828 KB |
5.txt | TLE | 2163 ms | 1012548 KB |
6.txt | TLE | 2163 ms | 1013412 KB |
7.txt | TLE | 2165 ms | 1005140 KB |
8.txt | TLE | 2164 ms | 1002408 KB |
9.txt | TLE | 2165 ms | 1006280 KB |
sample1.txt | AC | 4 ms | 16640 KB |
sample2.txt | AC | 4 ms | 16640 KB |
sample3.txt | AC | 7 ms | 17792 KB |