This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: Atreus
* created: 09.02.2019
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 500 + 10;
string s[maxn];
int a[30], b[30];
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> s[i];
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
int pre = 0, suf = n - 1;
for (int k = 0; k < n and s[i][k] == s[j][k]; k++)
pre ++;
for (int k = n - 1; k >= 0 and s[i][k] == s[j][k]; k--)
suf --;
if (suf - pre + 1 > m)
continue;
memset(a, 0, sizeof a), memset(b, 0, sizeof b);
for (int k = pre; k <= suf; k++){
a[int(s[i][k] - 'a')] ++;
b[int(s[j][k] - 'a')] ++;
}
bool found = 0;
for (int k = 0; k < 26; k++)
if (a[k] != b[k])
found = 1;
if (!found)
return cout << "DA\n", 0;
}
}
cout << "NE\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |