| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 200895 | SamAnd | Lozinke (COCI17_lozinke) | C++17 | 112 ms | 8440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 20004;
int n;
string a[N];
int z;
int t[N * 11][26];
int q[N * 11];
int main()
{
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n; ++i)
{
int m = a[i].size();
int pos = 0;
for (int j = 0; j < m; ++j)
{
if (!t[pos][a[i][j] - 'a'])
t[pos][a[i][j] - 'a'] = ++z;
pos = t[pos][a[i][j] - 'a'];
}
++q[pos];
}
long long ans = 0;
for (int i = 0; i < n; ++i)
{
int m = a[i].size();
set<int> s;
for (int l = 0; l < m; ++l)
{
int pos = 0;
for (int j = l; j < m; ++j)
{
if (!t[pos][a[i][j] - 'a'])
break;
pos = t[pos][a[i][j] - 'a'];
if (s.find(pos) == s.end())
ans += q[pos];
s.insert(pos);
}
}
--ans;
}
cout << ans << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
