답안 #144271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144271 2019-08-16T12:48:42 Z Divia Lozinke (COCI17_lozinke) C++14
40 / 100
24 ms 760 KB
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
//ifstream cin("lozinke.in");
//ofstream cout("lozinke.out");
int n,i,j,k,sol;
string s[2005],aux;
set <string> sett;
map <string,int> mapp;
set <string> ::iterator it;
map <string,int> ::iterator itt;
int cmp(string a,string b){
    if(a.size()!=b.size())return a.size()<b.size();
    return a<b;
}
int main(){
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>s[i];
    sort(s+1,s+n+1,cmp);
    for(i=1;i<=n;i++){
        sett.clear();
        for(j=0;j<s[i].size();j++){
            aux.erase(aux.begin(),aux.end());
            for(k=j;k<s[i].size();k++){
               aux.push_back(s[i][k]);
               sett.insert(aux);
            }
        }
        for(it=sett.begin();it!=sett.end();it++)
            if(mapp.find(*it)!=mapp.end())
                sol+=mapp[*it];
        if(mapp.find(s[i])!=mapp.end())
            mapp[s[i]]++;
        else mapp[s[i]]=1;
    }
    for(itt=mapp.begin();itt!=mapp.end();itt++)
        sol+=(itt->second)*(itt->second-1)/2;
    cout<<sol;
    return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:26:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0;j<s[i].size();j++){
                 ~^~~~~~~~~~~~
lozinke.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(k=j;k<s[i].size();k++){
                     ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 11 ms 504 KB Output is correct
6 Correct 17 ms 508 KB Output is correct
7 Correct 20 ms 504 KB Output is correct
8 Correct 24 ms 504 KB Output is correct
9 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)