# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
935986 | sapientsapiens | Lozinke (COCI17_lozinke) | C++14 | 88 ms | 856 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 <iostream>
#include <string>
#include <utility>
using namespace std;
int n;
string str[2005];
int ans = 0;
bool check(string a, string b) // checks if a is contained in b
{
if(a.size() > b.size()) {
swap(a, b);
}
for(int i = 0; i < b.size(); i++) {
if(b[i] == a[0]) {
bool c = true;
for(int j = 0; j < a.size(); j++) {
if(b[i + j] != a[j]){
c = false;
break;
}
}
if(c) return true;
}
}
return false;
}
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> str[i];
}
for(int i = 0; i < n; i++) {
for(int j = i+ 1; j < n; j++) {
if(str[i] == str[j]) {
ans += 2;
continue;
}
if(check(str[i], str[j])) ans++;
//test i on j
}
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |