Submission #677607

#TimeUsernameProblemLanguageResultExecution timeMemory
677607MariabfLozinke (COCI17_lozinke)C++17
40 / 100
1097 ms1108 KiB
#include<bits/stdc++.h> using namespace std; bool comp(string a, string b){ for(int i=0; i<a.size(); i++){ for(int j=0; j<b.size(); j++){ if(a[i+j]!=b[j])break; if(j==b.size()-1)return true; } } return false; } int main(){ int n; cin>>n; vector<string>v(n); for(int i=0; i<n; i++){ cin>>v[i]; }int ans=0; for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ if(v[i].size()>v[j].size()){ ans+=comp(v[i], v[j]); } else if(v[i].size()==v[j].size()){ ans+=2*comp(v[j], v[i]); } else{ ans+=comp(v[j], v[i]); } } }cout<<ans; }

Compilation message (stderr)

lozinke.cpp: In function 'bool comp(std::string, std::string)':
lozinke.cpp:4:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 |     for(int i=0; i<a.size(); i++){
      |                  ~^~~~~~~~~
lozinke.cpp:5:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |         for(int j=0; j<b.size(); j++){
      |                      ~^~~~~~~~~
lozinke.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |             if(j==b.size()-1)return true;
      |                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...