# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138628 | KCSC | Lozinke (COCI17_lozinke) | C++14 | 512 ms | 16580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int DIM = 20005;
string str[DIM];
char aux[DIM];
map<string, int> mmp;
void solve(int n) {
mmp.clear();
for (int i = 1; i <= n; ++i) {
set<string> mst;
for (int p1 = 0; p1 < str[i].length(); ++p1)
for (int p2 = p1; p2 < str[i].length(); ++p2)
mst.insert(str[i].substr(p1, p2 - p1 + 1));
for (string s : mst)
mmp[s]++;
}
}
int main(void) {
#ifdef HOME
freopen("lozinke.in", "r", stdin);
freopen("lozinke.out", "w", stdout);
#endif
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%s", aux + 1);
int m = strlen(aux + 1);
for (int j = 1; j <= m; ++j)
str[i].push_back(aux[j]);
}
solve(n);
int ans = 0;
for (int i = 1; i <= n; ++i)
ans += mmp[str[i]];
cout << ans - n;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |