# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116927 | FutymyClone | Lozinke (COCI17_lozinke) | C++14 | 362 ms | 43896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 5;
int n, ans = 0;
map <string, bitset <N> > mm;
string a[N];
bitset <N> temp;
map <string, int> mm2;
bool cmp (string s, string t) {
if (s.length() != t.length()) return s.length() < t.length();
return s < t;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], mm2[a[i]]++;
sort(a + 1, a + n + 1, cmp);
//for (int i = 1; i <= n; i++) cout << a[i] << "\n";
for (int i = 1; i <= n; i++) {
temp.reset();
for (int l = 0; l < a[i].length(); l++) {
for (int r = 0; r < a[i].length(); r++) {
string t = a[i].substr(l, r - l + 1);
if (mm.count(t)) temp |= mm[t];
}
}
ans += temp.count();
mm[a[i]].set(i);
}
for (auto i: mm2) ans += i.second * (i.second - 1) / 2;
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |