This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// iee
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);
template <class T> void read(T &x) {
x = 0;
int f = 1, ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + (ch - '0');
ch = getchar();
}
x *= f;
}
int main() {
int TT = 1; // cin >> TT;
rep(CAS, 1, TT)
work(CAS);
return 0;
}
const int N = 505;
int n, k;
char s[N][N];
int cnt[26];
bool chk(int x, int y) {
int l = -1, r = -1;
rep(i, 1, n) if (s[x][i] != s[y][i]) {
if (l == -1) l = i;
r = i;
}
if (l == -1) return 1;
if (r - l + 1 > k) return 0;
memset(cnt, 0, sizeof cnt);
rep(i, 1, n) cnt[s[x][i] - 'a']++;
rep(i, 1, n) cnt[s[y][i] - 'a']--;
rep(i, 0, 25) if (cnt[i]) return 0;
return 1;
}
void work(int CASE) {
read(n), read(k);
rep(i, 1, n) scanf("%s", s[i] + 1);
rep(i, 1, n) rep(j, i + 1, n) if (chk(i, j)) { puts("DA"); return; }
puts("NE");
}
Compilation message (stderr)
ispit.cpp: In function 'void work(int)':
ispit.cpp:53:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | rep(i, 1, n) scanf("%s", s[i] + 1);
| ~~~~~^~~~~~~~~~~~~~~~
# | 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... |