// [ нvмegy ]
// OLPCHUYENTIN2023 GOTOHUE
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int long long
#define all(c) c.begin(), c.end()
#ifdef hvmegy
#define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr << "[" << vars << " : ";
string delim = "";
(..., (cerr << delim << values, delim = ", "));
cerr << "]" << '\n';
}
#else
#define dbg(...)
#endif
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
int GOTOHUE();
void init();
int32_t main()
{
cin.tie(0) -> sync_with_stdio(0);
cout << fixed << setprecision(15);
#ifdef hvmegy
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("log.txt", "w", stderr);
#endif
// =============================
bool MULTITEST = 0;
// =============================
init();
int OLPCHUYENTIN2023 = 1;
if (MULTITEST) cin >> OLPCHUYENTIN2023;
for (int i = 1; i <= OLPCHUYENTIN2023; i++) {
if (GOTOHUE()) break;
#ifdef hvmegy
cout << "--ENDTEST--" << '\n';
cerr << "--ENDTEST--" << '\n';
#endif
}
#ifdef hvmegy
cerr << '\n' << clock() * 1000.0 / CLOCKS_PER_SEC << "ms" << '\n';
#endif
return 0;
}
void init() {
}
int GOTOHUE() {
int n;
cin >> n;
map<string, int> mp;
vector<string> s(n + 1);
for (int i = 1; i <= n; i++) {
cin >> s[i];
mp[s[i]]++;
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int l = 0; l < s[i].size(); l++) {
string t;
for (int r = l; r < s[i].size(); r++) {
t += s[i][r];
if (mp.count(t)) {
ans += mp[t] - (l == 0 && r == s[i].size() - 1);
}
}
}
}
cout << ans;
return 0;
}
Compilation message
lozinke.cpp: In function 'long long int GOTOHUE()':
lozinke.cpp:76:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
76 | for (int l = 0; l < s[i].size(); l++) {
| ~~^~~~~~~~~~~~~
lozinke.cpp:78:43: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for (int r = l; r < s[i].size(); r++) {
| ~~^~~~~~~~~~~~~
lozinke.cpp:81:69: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
81 | ans += mp[t] - (l == 0 && r == s[i].size() - 1);
| ~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
556 KB |
Output isn't correct |
6 |
Incorrect |
6 ms |
604 KB |
Output isn't correct |
7 |
Incorrect |
7 ms |
860 KB |
Output isn't correct |
8 |
Correct |
8 ms |
604 KB |
Output is correct |
9 |
Incorrect |
43 ms |
1244 KB |
Output isn't correct |
10 |
Correct |
44 ms |
1372 KB |
Output is correct |
11 |
Incorrect |
70 ms |
1880 KB |
Output isn't correct |
12 |
Correct |
85 ms |
1628 KB |
Output is correct |
13 |
Incorrect |
118 ms |
2192 KB |
Output isn't correct |
14 |
Incorrect |
91 ms |
2396 KB |
Output isn't correct |
15 |
Correct |
104 ms |
2256 KB |
Output is correct |
16 |
Incorrect |
93 ms |
1368 KB |
Output isn't correct |
17 |
Correct |
13 ms |
1116 KB |
Output is correct |
18 |
Incorrect |
17 ms |
1116 KB |
Output isn't correct |
19 |
Incorrect |
90 ms |
2136 KB |
Output isn't correct |
20 |
Incorrect |
67 ms |
1368 KB |
Output isn't correct |