# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116822 | manh9203 | Lozinke (COCI17_lozinke) | C++17 | 632 ms | 30396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
bool cmp(string a,string b){
return a.length() < b.length();
}
long long n,ans;
string s[20005];
unordered_map<string,int> cnt1,cnt2;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>s[i];
sort(s+1,s+1+n,cmp);
for(int i=1;i<=n;i++){
unordered_map<string,bool> check;
for(int len=1;len<=s[i].length();len++){
for(int j=0;j+len-1<s[i].length();j++){
string tmp=s[i].substr(j,len);
if(check[tmp]==0){
ans=ans+cnt1[tmp];
check[tmp]=1;
}
}
}
cnt1[s[i]]++;
}
for(int i=n;i>=1;i--){
unordered_map<string,bool> check;
for(int len=1;len<=s[i].length();len++){
for(int j=0;j+len-1<s[i].length();j++){
string tmp=s[i].substr(j,len);
if(check[tmp]==0){
ans=ans+cnt2[tmp];
check[tmp]=1;
}
}
}
cnt2[s[i]]++;
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |