# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712768 | aVe | Lozinke (COCI17_lozinke) | C++14 | 375 ms | 16584 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>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
ll set_on(int n, int k){
return (n |= 1 << k);
}
ll set_off(int n, int k){
return (n &= ~(1UL << k));
}
bool check_bit(int n, int k){
int bit = (n >> k) & 1U;
if(bit == 1)
return true;
return false;
}
vector<char> next[11]; // next[0] - first characters
int add[11][26];
vector<string> pass;
int n;
bool comp(string& A, string& B){
if(A.size() < B.size())
return true;
return false;
}
int main(){
cin>>n;
for(int i = 0; i < n; i++){
string str;
cin>>str;
pass.pb(str);
}
sort(pass.begin(), pass.end(), comp);
int ans = 0;
map<string, int> seen;
for(int i = 0; i < n; i++){
string str = pass[i];
map<string,int> done;
ans+= seen[str];
for(int j = 0; j < str.size(); j++){
for(int k = j; k < str.size(); k++){
string check;
for(int z = j; z <= k; z++)
check.pb(str[z]);
if(done[check] == 0 && seen[check]>0){
//cout<<str<<" "<<check<<endl;
done[check] = 1;
ans += seen[check];
}
}
}
seen[str]++;
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |