#include <bits/stdc++.h>
#define gc getchar
#define rep(i, a, b) for(int i=a;i<=b;i++)
#define rep2(i, a, b) for(int i=a;i>=b;--i)
#define wipe(a, b) memset(a, b, sizeof a);
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef pair<int, int> pii;
inline int scan(){
int n=0, x=gc(), s=1;
for(;x<'0'||x>'9';x=gc()) if(x=='-') s=-1;
for(;x>='0'&&x<='9';x=gc()) n = 10*n + x - '0';
return n*s;
}
int gcd(int a, int b){
return (b?gcd(b, a%b):a);
}
int main(){
ios::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
vector<string> str;
for(int i=1;i<=n;i++){
string x;
cin >> x;
str.push_back(x);
}
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i == j) continue;
if(str[i].size() < str[j].size()) continue;
// Checar s(j) substring de s(i)
for(int l=0;l<=(int)str[i].size()-str[j].size();l++){
int qtd=0;
while(qtd < str[j].size()){
if(str[i][qtd+l] == str[j][qtd]) qtd++;
else break;
}
if(qtd == str[j].size()){
ans++;
break;
}
}
}
}
cout << ans << "\n";
return 0;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:42:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int l=0;l<=(int)str[i].size()-str[j].size();l++){
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lozinke.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(qtd < str[j].size()){
~~~~^~~~~~~~~~~~~~~
lozinke.cpp:48:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(qtd == str[j].size()){
~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
432 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
21 ms |
688 KB |
Output is correct |
6 |
Correct |
53 ms |
696 KB |
Output is correct |
7 |
Correct |
61 ms |
844 KB |
Output is correct |
8 |
Correct |
45 ms |
844 KB |
Output is correct |
9 |
Execution timed out |
1091 ms |
1264 KB |
Time limit exceeded |
10 |
Execution timed out |
1063 ms |
1456 KB |
Time limit exceeded |
11 |
Execution timed out |
1068 ms |
1456 KB |
Time limit exceeded |
12 |
Execution timed out |
1071 ms |
1700 KB |
Time limit exceeded |
13 |
Execution timed out |
1084 ms |
2300 KB |
Time limit exceeded |
14 |
Execution timed out |
1056 ms |
2476 KB |
Time limit exceeded |
15 |
Execution timed out |
1058 ms |
2604 KB |
Time limit exceeded |
16 |
Execution timed out |
1042 ms |
2764 KB |
Time limit exceeded |
17 |
Execution timed out |
1058 ms |
2972 KB |
Time limit exceeded |
18 |
Execution timed out |
1063 ms |
3184 KB |
Time limit exceeded |
19 |
Execution timed out |
1061 ms |
3364 KB |
Time limit exceeded |
20 |
Execution timed out |
1074 ms |
3508 KB |
Time limit exceeded |