Submission #232479

# Submission time Handle Problem Language Result Execution time Memory
232479 2020-05-17T07:20:14 Z NONAME Ispit (COCI19_ispit) C++17
90 / 90
33 ms 29440 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

int n, k;
int pf[501][501][26];
string s[N];

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

//    in("input.txt");

    cin >> n >> k;

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

        for (int j = 0; j < n; j++) {
            for (int t = 0; t < 26; t++)
                pf[i][j][t] = (j - 1 < 0 ? 0 : pf[i][j - 1][t]);

            pf[i][j][s[i][j] - 'a']++;
        }
    }

    for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
        int l = 0, r = n - 1;
        while (l < r && s[i][l] == s[j][l])
            l++;

        while (l < r && s[i][r] == s[j][r])
            r--;

        if (r - l + 1 > k)
            continue;

        bool f = 1;

        for (int t = 0; t < 26 && f; t++)
            f = ((pf[i][r][t] - (l - 1 < 0 ? 0 : pf[i][l - 1][t])) == (pf[j][r][t] - (l - 1 < 0 ? 0 : pf[j][l - 1][t])));

        if (f) {
            cout << "DA";
            return 0;
        }
    }

    cout << "NE";
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 6 ms 3584 KB Output is correct
3 Correct 7 ms 3584 KB Output is correct
4 Correct 7 ms 3584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3584 KB Output is correct
2 Correct 6 ms 3456 KB Output is correct
3 Correct 6 ms 3584 KB Output is correct
4 Correct 6 ms 3584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3584 KB Output is correct
2 Correct 6 ms 3584 KB Output is correct
3 Correct 6 ms 3584 KB Output is correct
4 Correct 7 ms 3456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8448 KB Output is correct
2 Correct 10 ms 8448 KB Output is correct
3 Correct 11 ms 8448 KB Output is correct
4 Correct 10 ms 8448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8448 KB Output is correct
2 Correct 10 ms 8448 KB Output is correct
3 Correct 9 ms 8448 KB Output is correct
4 Correct 11 ms 8448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8448 KB Output is correct
2 Correct 10 ms 8448 KB Output is correct
3 Correct 10 ms 8448 KB Output is correct
4 Correct 10 ms 8480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8448 KB Output is correct
2 Correct 10 ms 8448 KB Output is correct
3 Correct 11 ms 8448 KB Output is correct
4 Correct 10 ms 8448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 29312 KB Output is correct
2 Correct 33 ms 29184 KB Output is correct
3 Correct 24 ms 29184 KB Output is correct
4 Correct 25 ms 29440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 29312 KB Output is correct
2 Correct 25 ms 29184 KB Output is correct
3 Correct 26 ms 29184 KB Output is correct
4 Correct 27 ms 29440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 29312 KB Output is correct
2 Correct 23 ms 29216 KB Output is correct
3 Correct 25 ms 29184 KB Output is correct
4 Correct 24 ms 29440 KB Output is correct