# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472778 | Mr_Ph | Lozinke (COCI17_lozinke) | C++14 | 480 ms | 16348 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.
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int dx[4] = {0, 0, 1, -1};
//int dy[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
bool cmp(const string &a,const string &b)
{
return a.sz<b.sz;
}
void solve()
{
int n;
cin>>n;
vector<string>arr(n);
ent(arr);
sort(all(arr),cmp);
map<string,int>mp;
ll cnt=0;
for(int i=0; i<n; i++)
{
map<string,int>mp1;
for(int k=0; k<arr[i].sz; k++)
{
string c;
for(int e=k; e<arr[i].sz; e++)
{
c+=arr[i][e];
if(!mp1[c])
{
mp[c]++;
mp1[c]++;
}
}
}
}
for(int i=0;i<n;i++)
cnt+=mp[arr[i]]-1;
cout<<cnt<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
//freopen("window.in","r",stdin);
//freopen("output.txt","w",stdout);
int t=1;//int st;
//cin>>t;//cin>>st;
while(t--)
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |