Submission #472760

#TimeUsernameProblemLanguageResultExecution timeMemory
472760MamdouhNLozinke (COCI17_lozinke)C++14
40 / 100
1090 ms6556 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" int n,ans; string password[200002]; void check(string a,string b) { int sizeofb = b.size(); for(int i = 0;i<a.size();i++) { if(i+b.size()>a.size())break; if(a[i]==b[0]) { int x=i; int j=0; int sz=0; while(a[x]==b[j]&&x<a.size()&&j<sizeofb) { sz++; j++; x++; } if(sz==sizeofb) { ans++; return; } } } } main() { cin>>n; for(int i=0;i<n;i++)cin>>password[i]; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(j==i)continue; if(password[j].size()>password[i].size())continue; //cout<<password[i]<<" "<<password[j]<<endl; check(password[i],password[j]); } } cout<<ans<<endl; }

Compilation message (stderr)

lozinke.cpp: In function 'void check(std::string, std::string)':
lozinke.cpp:12:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0;i<a.size();i++)
      |                   ~^~~~~~~~~
lozinke.cpp:20:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             while(a[x]==b[j]&&x<a.size()&&j<sizeofb)
      |                               ~^~~~~~~~~
lozinke.cpp: At global scope:
lozinke.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...