Submission #934304

#TimeUsernameProblemLanguageResultExecution timeMemory
934304dubious_dudeLozinke (COCI17_lozinke)C++17
0 / 100
1096 ms1116 KiB
#include <bits/stdc++.h> using namespace std; #define fast_io cin.tie(0)->sync_with_stdio(false); bool isTrue(string &s1, string &s2) { if(s1 == s2) return true; int i=0,j=0; pair<int,int> ss1 = {0,0}; pair<int,int> ss2 = {0,0}; while(i<s1.size() && j<s2.size()) { if(s1[i] == s2[j]) { i++; j++; ss1.second++; ss2.second++; } else { if(s1.size() > s2.size()) { j=0; i++; ss2 = {0,0}; ss1 = {i,i}; } else { i=0; j++; ss1 = {0,0}; ss2 = {i,i}; } } } string c1 = s1.substr(ss1.first, ss1.second - ss1.first); string c2 = s2.substr(ss2.first, ss2.second - ss2.first); return (c1 == c2 && !c1.empty()); } int main() { fast_io; int n; cin >> n; vector<string> pass(n); for(int i=0; i<n; i++) cin >> pass[i]; int res = 0; for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { res += (isTrue(pass[i],pass[j]) ? 1 : 0); res += (pass[i] == pass[j]) ? 1 : 0; } } cout << res; return 0; }

Compilation message (stderr)

lozinke.cpp: In function 'bool isTrue(std::string&, std::string&)':
lozinke.cpp:12:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     while(i<s1.size() && j<s2.size()) {
      |           ~^~~~~~~~~~
lozinke.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     while(i<s1.size() && j<s2.size()) {
      |                          ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...