답안 #472773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472773 2021-09-14T10:03:05 Z Mr_OK_Man Lozinke (COCI17_lozinke) C++17
100 / 100
411 ms 16404 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
   // cout << "Hello world!" << endl;
   long long n,c=0;
   cin>>n;
   vector<string>a(n);
  map<string,long long>mp;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];

       mp[a[i]]++;
   }
   //sort(a.begin(),a.end());
set<string>s;
   for(int i=0;i<n;i++)
   {
       //COUNT ALL OCCURNCES IN A SET
s.clear();
       for(int j=0;j<a[i].size();j++)
       {
           string h="";
          /* h+=a[i].substr(j,a[i].size()-j);
           cout<<h<<endl;
string k="";
k+=a[i].substr(0,j);
cout<<k<<endl;
             s.insert(h);
 s.insert(k);*/
 for(int l=j;l<a[i].size();l++)
 {
    h+=a[i][l];
     s.insert(h);
 }
       }
for(auto i:s)
   {
       c+=mp[i];
   }
   }

  /* for(auto i:a)
   {
       cout<<i<<endl;
       c+=mp[i]-1;
   }*/
   cout<<c-n<<endl;//#HABDA

    return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |        for(int j=0;j<a[i].size();j++)
      |                    ~^~~~~~~~~~~~
lozinke.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int l=j;l<a[i].size();l++)
      |              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 9 ms 604 KB Output is correct
6 Correct 18 ms 588 KB Output is correct
7 Correct 19 ms 1332 KB Output is correct
8 Correct 34 ms 2160 KB Output is correct
9 Correct 90 ms 2344 KB Output is correct
10 Correct 176 ms 7364 KB Output is correct
11 Correct 157 ms 4148 KB Output is correct
12 Correct 392 ms 16404 KB Output is correct
13 Correct 254 ms 2608 KB Output is correct
14 Correct 260 ms 14780 KB Output is correct
15 Correct 411 ms 16284 KB Output is correct
16 Correct 253 ms 1076 KB Output is correct
17 Correct 77 ms 844 KB Output is correct
18 Correct 61 ms 908 KB Output is correct
19 Correct 270 ms 8436 KB Output is correct
20 Correct 128 ms 1064 KB Output is correct