# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472778 |
2021-09-14T10:10:29 Z |
Mr_Ph |
Lozinke (COCI17_lozinke) |
C++14 |
|
480 ms |
16348 KB |
///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
lozinke.cpp: In function 'void solve()':
lozinke.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
| ~^~~~~~~~~~~
lozinke.cpp:32:5: note: in expansion of macro 'ent'
32 | ent(arr);
| ^~~
lozinke.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int k=0; k<arr[i].sz; k++)
| ^
lozinke.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int e=k; e<arr[i].sz; e++)
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
10 ms |
716 KB |
Output is correct |
6 |
Correct |
15 ms |
652 KB |
Output is correct |
7 |
Correct |
20 ms |
1456 KB |
Output is correct |
8 |
Correct |
34 ms |
2296 KB |
Output is correct |
9 |
Correct |
85 ms |
2352 KB |
Output is correct |
10 |
Correct |
193 ms |
7344 KB |
Output is correct |
11 |
Correct |
136 ms |
4152 KB |
Output is correct |
12 |
Correct |
480 ms |
16348 KB |
Output is correct |
13 |
Correct |
276 ms |
2596 KB |
Output is correct |
14 |
Correct |
271 ms |
14900 KB |
Output is correct |
15 |
Correct |
412 ms |
16196 KB |
Output is correct |
16 |
Correct |
323 ms |
1032 KB |
Output is correct |
17 |
Correct |
69 ms |
844 KB |
Output is correct |
18 |
Correct |
44 ms |
844 KB |
Output is correct |
19 |
Correct |
257 ms |
8516 KB |
Output is correct |
20 |
Correct |
133 ms |
1020 KB |
Output is correct |