hi everybody, this day i wanna teach how to solve 71A - Way Too Long Words with DP
include<bits//stdc++.h>
using namespace std; int check_size(string a){ //this function can calc lenght your string int c=0; vectors; for(auto&i:a)s.push_back(i),c++; assert(c>=s.size()); return max(c,(int)s.size()); } struct DP{ string a; void read(){ cin>>a; } int middle_number(int n){ // calc middle number vectordp(n); for(int i=0;i<n;++i){ dp[i]=(i and i+110); if(i>0)dp[i]+=dp[i-1]; } return dp[n-1]; } char get(int i,int n){ for(int j=0;j<n;j++)if(j==i) return a[j]; return '*'; } string ans(){ int n=check_size(a),nm=middle_number(n); string answer=get(0,n)+to_string(nm)+get(n-1,n); if(n<=10)answer=a; return answer; } }; int main() { int n; cin>>n; while(n--){ DP dp; dp.read(); cout<<dp.ans()<<'\n'; } } after 20 like i share solutions this problem 231A - Team








MORE GREEEDY
more DP
So more greedy dp
Hzoooooooooooor