# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80269 | pamaj | Lozinke (COCI17_lozinke) | C++14 | 1091 ms | 2752 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.
#include <bits/stdc++.h>
using namespace std;
// struct node
// {
// bool ok = false;
// node *b[26];
// };
// bool find(const string& s)
// {
// }
// bool insert(const string& s, node* a)
// {
// for(auto u : s)
// {
// }
// }
bool find(const string& a, const string& b)
{
if(a.size() < b.size()) return false;
for(int i = 0; i < a.size(); i++)
{
bool ok = false;
for(int j = 0; j < b.size(); j++)
{
if(i + j >= a.size()) break;
if(a[i + j] != b[j])
break;
if(j == b.size() - 1) return true;
}
}
return false;
}
int main()
{
ios::sync_with_stdio(false), cin.tie(nullptr);
int n;
cin >> n;
vector<string> ps;
int ans = 0;
for(int i = 0; i < n; i++)
{
string s;
cin >> s;
ps.push_back(s);
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(i == j) continue;
if(find(ps[i],ps[j])) ans++;
}
}
cout << ans << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |