# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97758 | dalgerok | Lozinke (COCI17_lozinke) | C++17 | 805 ms | 38340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
struct super_hash{
size_t operator()(string x)const{
unsigned long long cur = 0, p = 1;
for(auto it : x){
cur += p * it;
p *= 59;
}
return cur;
}
};
gp_hash_table < string, int > q;
inline void add(string &s){
gp_hash_table < string, int > used;
for(int i = 0; i < (int)s.size(); i++){
string t;
for(int j = i; j < (int)s.size(); j++){
t += s[j];
if(used.find(t) == used.end()){
q[t] += 1;
used[t] = true;
}
}
}
}
inline void del(string &s){
gp_hash_table < string, int > used;
for(int i = 0; i < (int)s.size(); i++){
string t;
for(int j = i; j < (int)s.size(); j++){
t += s[j];
if(used.find(t) == used.end()){
q[t] -= 1;
used[t] = false;
}
}
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
string s[n];
for(int i = 0; i < n; i++){
cin >> s[i];
add(s[i]);
}
int ans = 0;
for(int i = 0; i < n; i++){
del(s[i]);
ans += q[s[i]];
add(s[i]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |