#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));
int fx[]={1,-1,0,0}, fy[]={0,0,1,-1};
int main() {
/*freopen("measurement.in","r",stdin);
freopen("measurement.out","w", stdout);*/
x_x
int n; cin>>n; string ar[n]; map<string,int>mp;
for (auto&i:ar) cin>>i, mp[i]++;
ll ans=0;
for (int i=0; i<n; i++ ){
mp[ar[i]]--;
for (int j=0; j<n; j++) {
for (int k=0; (k+j)<=ar[i].size(); k++) {
if (mp.find(ar[i].substr(k,j))!=mp.end()) ans+=mp[ar[i].substr(k,j)];
}
}
++mp[ar[i]];
}
cout<<ans;
return 0;
}
Compilation message
lozinke.cpp: In function 'int main()':
lozinke.cpp:32:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int k=0; (k+j)<=ar[i].size(); k++) {
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
9 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
15 ms |
604 KB |
Output isn't correct |
8 |
Correct |
14 ms |
616 KB |
Output is correct |
9 |
Incorrect |
173 ms |
1116 KB |
Output isn't correct |
10 |
Correct |
261 ms |
1256 KB |
Output is correct |
11 |
Incorrect |
590 ms |
1628 KB |
Output isn't correct |
12 |
Correct |
639 ms |
1628 KB |
Output is correct |
13 |
Incorrect |
753 ms |
2080 KB |
Output isn't correct |
14 |
Incorrect |
995 ms |
2348 KB |
Output isn't correct |
15 |
Execution timed out |
1010 ms |
1880 KB |
Time limit exceeded |
16 |
Incorrect |
999 ms |
1172 KB |
Output isn't correct |
17 |
Correct |
725 ms |
1048 KB |
Output is correct |
18 |
Incorrect |
719 ms |
1052 KB |
Output isn't correct |
19 |
Incorrect |
916 ms |
2020 KB |
Output isn't correct |
20 |
Execution timed out |
1027 ms |
1272 KB |
Time limit exceeded |