답안 #170362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170362 2019-12-24T22:01:22 Z mdn2002 Lozinke (COCI17_lozinke) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n,ans;
map<string,int>mp;
map<pair<string,int>,int>m;
vector<string>v;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("lemonade.in","r",stdin);
    //freopen("lemonade.out","w",stdout);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
        mp[s]++;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            string s;
            for(int z=j;z<v[i].size();z++)
            {
                s.push_back(v[i][z]);
                if(m[s]==0)
                {
                    ans+=mp[s];
                    m[s]++;
                }
            }
        }
        m.clear();
    }
    cout<<ans-n;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:25:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v[i].size();j++)
                     ~^~~~~~~~~~~~
lozinke.cpp:28:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int z=j;z<v[i].size();z++)
                         ~^~~~~~~~~~~~
lozinke.cpp:31:21: error: no match for 'operator[]' (operand types are 'std::map<std::pair<std::__cxx11::basic_string<char>, int>, int>' and 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}')
                 if(m[s]==0)
                     ^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from lozinke.cpp:1:
/usr/include/c++/7/bits/stl_map.h:484:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<std::__cxx11::basic_string<char>, int>; _Tp = int; _Compare = std::less<std::pair<std::__cxx11::basic_string<char>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::__cxx11::basic_string<char>, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<std::__cxx11::basic_string<char>, int>]
       operator[](const key_type& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:484:7: note:   no known conversion for argument 1 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const key_type& {aka const std::pair<std::__cxx11::basic_string<char>, int>&}'
/usr/include/c++/7/bits/stl_map.h:504:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<std::__cxx11::basic_string<char>, int>; _Tp = int; _Compare = std::less<std::pair<std::__cxx11::basic_string<char>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::__cxx11::basic_string<char>, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<std::__cxx11::basic_string<char>, int>]
       operator[](key_type&& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:504:7: note:   no known conversion for argument 1 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'std::map<std::pair<std::__cxx11::basic_string<char>, int>, int>::key_type&& {aka std::pair<std::__cxx11::basic_string<char>, int>&&}'
lozinke.cpp:34:22: error: no match for 'operator[]' (operand types are 'std::map<std::pair<std::__cxx11::basic_string<char>, int>, int>' and 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}')
                     m[s]++;
                      ^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from lozinke.cpp:1:
/usr/include/c++/7/bits/stl_map.h:484:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<std::__cxx11::basic_string<char>, int>; _Tp = int; _Compare = std::less<std::pair<std::__cxx11::basic_string<char>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::__cxx11::basic_string<char>, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<std::__cxx11::basic_string<char>, int>]
       operator[](const key_type& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:484:7: note:   no known conversion for argument 1 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'const key_type& {aka const std::pair<std::__cxx11::basic_string<char>, int>&}'
/usr/include/c++/7/bits/stl_map.h:504:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<std::__cxx11::basic_string<char>, int>; _Tp = int; _Compare = std::less<std::pair<std::__cxx11::basic_string<char>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::__cxx11::basic_string<char>, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<std::__cxx11::basic_string<char>, int>]
       operator[](key_type&& __k)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_map.h:504:7: note:   no known conversion for argument 1 from 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}' to 'std::map<std::pair<std::__cxx11::basic_string<char>, int>, int>::key_type&& {aka std::pair<std::__cxx11::basic_string<char>, int>&&}'