Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL); #define ll long long #define sz(s) (int)(s).size() #define all(s) (s).begin(),(s).end() using namespace std; void File(); void sol(); const int N=5001; string s; int n; int common[N][N]; int dp[N][N]; int get(int i,int j){ if(j==n)return 0; int &ret=common[i][j]; if(~ret)return ret; ret=0; if(s[i]==s[j])ret=1+get(i+1,j+1); return ret; } int rec(int i,int last){ if(i>n)return -1e9; if(i==n)return 0; int &ret=dp[i][last]; if(~ret)return ret; ret=-1e9; if(last!=0) { ret = max(ret, rec(i + 1, last + 1)); int c=min(last+1,get(i-last,i)); int i1=i-last+c,i2=i+c; if(c>=last)ret=max(ret,1+rec(i+last+1,last+1)); else if(s[i1]
=last && ret==1+rec(i+last+1,last+1)) { cout<
> t; while (t--) { sol(); } return 0; } void sol() { cin>>s; n=sz(s); memset(common,-1,sizeof common); memset(dp,-1,sizeof dp); cout<
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)