Submission #96615

# Submission time Handle Problem Language Result Execution time Memory
96615 2019-02-10T12:59:55 Z FutymyClone Ispit (COCI19_ispit) C++14
90 / 90
271 ms 640 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9 + 7;
const int N = 505;

int n, m, cnt[26];
char a[N][N];

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

    cin >> n >> m;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            memset(cnt, 0, sizeof(cnt));
            int f = -1, last = -1;
            for (int k = 1; k <= n; k++) {
                cnt[a[i][k] - 'a']++;
                cnt[a[j][k] - 'a']--;
                if (a[i][k] != a[j][k]) {
                    if (f == -1) f = k;
                    last = k;
                }
            }

            if (last - f + 1 <= m && count(cnt, cnt + 26, 0) == 26) return cout << "DA", 0;
        }
    }

    cout << "NE";
    return 0;
}
/*
10 4
bkppucotbt
pctkuobbtp
tpktuobcbp
cpubotnptb
btpcupobnt
tbctponbpu
ktcpbpuotb
ctubpnpbot
bcnotutppb
ttcbppuobk
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 376 KB Output is correct
2 Correct 16 ms 504 KB Output is correct
3 Correct 17 ms 504 KB Output is correct
4 Correct 11 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 504 KB Output is correct
2 Correct 16 ms 376 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Correct 13 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 504 KB Output is correct
2 Correct 13 ms 480 KB Output is correct
3 Correct 13 ms 376 KB Output is correct
4 Correct 11 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 14 ms 504 KB Output is correct
4 Correct 15 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 271 ms 628 KB Output is correct
2 Correct 179 ms 632 KB Output is correct
3 Correct 151 ms 632 KB Output is correct
4 Correct 136 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 504 KB Output is correct
2 Correct 89 ms 504 KB Output is correct
3 Correct 191 ms 624 KB Output is correct
4 Correct 238 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 624 KB Output is correct
2 Correct 46 ms 628 KB Output is correct
3 Correct 200 ms 640 KB Output is correct
4 Correct 133 ms 636 KB Output is correct