# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
712768 |
2023-03-19T19:24:09 Z |
aVe |
Lozinke (COCI17_lozinke) |
C++14 |
|
375 ms |
16584 KB |
#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
lozinke.cpp: In function 'int main()':
lozinke.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int j = 0; j < str.size(); j++){
| ~~^~~~~~~~~~~~
lozinke.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int k = j; k < str.size(); k++){
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
9 ms |
700 KB |
Output is correct |
6 |
Correct |
15 ms |
724 KB |
Output is correct |
7 |
Correct |
20 ms |
1384 KB |
Output is correct |
8 |
Correct |
29 ms |
2224 KB |
Output is correct |
9 |
Correct |
102 ms |
2372 KB |
Output is correct |
10 |
Correct |
151 ms |
7472 KB |
Output is correct |
11 |
Correct |
148 ms |
4264 KB |
Output is correct |
12 |
Correct |
375 ms |
16584 KB |
Output is correct |
13 |
Correct |
252 ms |
2868 KB |
Output is correct |
14 |
Correct |
277 ms |
15036 KB |
Output is correct |
15 |
Correct |
336 ms |
16452 KB |
Output is correct |
16 |
Correct |
286 ms |
1660 KB |
Output is correct |
17 |
Correct |
99 ms |
1612 KB |
Output is correct |
18 |
Correct |
62 ms |
1632 KB |
Output is correct |
19 |
Correct |
235 ms |
8596 KB |
Output is correct |
20 |
Correct |
167 ms |
1548 KB |
Output is correct |