Submission #934304

# Submission time Handle Problem Language Result Execution time Memory
934304 2024-02-27T06:44:06 Z dubious_dude Lozinke (COCI17_lozinke) C++17
0 / 100
1000 ms 1116 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 4 ms 348 KB Output isn't correct
5 Incorrect 22 ms 492 KB Output isn't correct
6 Incorrect 60 ms 348 KB Output isn't correct
7 Incorrect 79 ms 592 KB Output isn't correct
8 Incorrect 71 ms 344 KB Output isn't correct
9 Execution timed out 1064 ms 604 KB Time limit exceeded
10 Execution timed out 1061 ms 860 KB Time limit exceeded
11 Execution timed out 1049 ms 976 KB Time limit exceeded
12 Execution timed out 1041 ms 860 KB Time limit exceeded
13 Execution timed out 1096 ms 1112 KB Time limit exceeded
14 Execution timed out 1052 ms 1116 KB Time limit exceeded
15 Execution timed out 1027 ms 1116 KB Time limit exceeded
16 Execution timed out 1038 ms 1116 KB Time limit exceeded
17 Execution timed out 1014 ms 1112 KB Time limit exceeded
18 Execution timed out 1057 ms 1116 KB Time limit exceeded
19 Execution timed out 1043 ms 1112 KB Time limit exceeded
20 Execution timed out 1058 ms 1116 KB Time limit exceeded