Submission #244838

# Submission time Handle Problem Language Result Execution time Memory
244838 2020-07-05T07:11:14 Z VEGAnn Rima (COCI17_rima) C++14
28 / 140
267 ms 22236 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
const int N = 500100;
string s[N];
int n, ans = 0;

bool ok(int i, int j){
    int ned = max(sz(s[i]), sz(s[j])) - 1;

    int lf = 0;

    while (lf < min(sz(s[i]), sz(s[j])) && s[i][lf] == s[j][lf])
        lf++;

    return bool(lf >= ned);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> s[i];

        reverse(all(s[i]));
    }

    sort(s, s + n);

    for (int i = 0; i < n; ){
        int j = i + 1;

        while (j < n && ok(j - 1, j))
            j++;

        ans = max(ans, j - i);

        i = j;
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 16000 KB Output isn't correct
2 Correct 16 ms 16000 KB Output is correct
3 Incorrect 13 ms 16000 KB Output isn't correct
4 Incorrect 267 ms 18680 KB Output isn't correct
5 Correct 32 ms 21760 KB Output is correct
6 Incorrect 17 ms 17304 KB Output isn't correct
7 Incorrect 17 ms 17060 KB Output isn't correct
8 Incorrect 16 ms 16880 KB Output isn't correct
9 Incorrect 40 ms 22236 KB Output isn't correct
10 Incorrect 16 ms 17092 KB Output isn't correct