# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029761 | earlyamazon | Savez (COCI15_savez) | C++14 | 1091 ms | 2644 KiB |
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 n <= 20, S <= 500
#include <bits/stdc++.h>
using namespace std;
const int mn = 503;
int n,wyn;
string t[mn];
bool ok[mn][mn];
bool czy1w2(string s1, string s2){
if (s1.size() > s2.size()) return 0;
for (int i = 0; i < 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++){
for (int j = i+1; j < n; j++){
if (czy1w2(t[i], t[j])){
ok[i][j] = 1;
}
}
}
for (int i = 1; i < (1<<n); i++){
vector<int> kt;
for (int j = 0; j < n; j++){
if ((1<<j)&i) kt.push_back(j);
}
bool czyok = 1;
for (int j = 1; j < kt.size(); j++){
if (!ok[kt[j-1]][kt[j]]) czyok = 0;
}
if (czyok) wyn = max(wyn, (int)kt.size());
}
cout<<wyn<<"\n";
}
Compilation message (stderr)
# | 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... |