This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// brut S <= 500
#include <bits/stdc++.h>
using namespace std;
const int mn = 1e6+7;
int n,wyn;
string t[mn];
int dp[mn];
bool czy1w2(string s1, string s2){
if (s1.size() > s2.size()) return 0;
for (int i = 0; i < (int)s1.size(); i++){
if (s1[i] != s2[i] || s1[s1.size()-i-1] != s2[s2.size()-i-1]) return 0;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
for (int i = 0; i < n; i++){
cin>>t[i];
}
for (int i = 0; i < n; i++){
dp[i] = 1;
for (int j = 0; j < i; j++){
if (czy1w2(t[j], t[i])){
dp[i] = max(dp[j]+1, dp[i]);
}
}
wyn = max(wyn, dp[i]);
}
cout<<wyn<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |