Submission #472748

# Submission time Handle Problem Language Result Execution time Memory
472748 2021-09-14T09:25:53 Z Mr_OK_Man Lozinke (COCI17_lozinke) C++17
40 / 100
1000 ms 2252 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());

   for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       {
           if(j==i){continue;}
if(a[i].size()>a[j].size())
{
    continue;
}
           for(int k=0;k<a[j].size();k++)
           {
              if(k+a[i].size()-1>a[j].size())
              {
                  break;
              }
           //cout<<a[i]<<" "<<a[j].substr(k,a[i].size())<<endl;
               if(a[j].substr(k,a[i].size())==a[i])
               {
                   c++;
                   break;
               }
           }
       }
   }
  /* for(auto i:a)
   {
       cout<<i<<endl;
       c+=mp[i]-1;
   }*/
   cout<<c<<endl;

    return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |            for(int k=0;k<a[j].size();k++)
      |                        ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 8 ms 204 KB Output is correct
5 Correct 46 ms 332 KB Output is correct
6 Correct 111 ms 424 KB Output is correct
7 Correct 182 ms 460 KB Output is correct
8 Correct 173 ms 464 KB Output is correct
9 Execution timed out 1089 ms 1100 KB Time limit exceeded
10 Execution timed out 1086 ms 1100 KB Time limit exceeded
11 Execution timed out 1088 ms 1484 KB Time limit exceeded
12 Execution timed out 1091 ms 1612 KB Time limit exceeded
13 Execution timed out 1095 ms 2232 KB Time limit exceeded
14 Execution timed out 1090 ms 2252 KB Time limit exceeded
15 Execution timed out 1095 ms 2048 KB Time limit exceeded
16 Execution timed out 1088 ms 1228 KB Time limit exceeded
17 Execution timed out 1098 ms 1100 KB Time limit exceeded
18 Execution timed out 1081 ms 1100 KB Time limit exceeded
19 Execution timed out 1091 ms 1996 KB Time limit exceeded
20 Execution timed out 1095 ms 1100 KB Time limit exceeded