# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
313950 | phathnv | Ispit (COCI19_ispit) | C++11 | 333 ms | 892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "ISPIT"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 502;
int n, k;
char a[N][N];
int d[26];
void readInput(){
scanf("%d %d", &n, &k);
for(int i = 1; i <= n; i++)
scanf("%s", a[i] + 1);
}
bool check(int x1, int x2){
for(int i = 0; i < 26; i++)
d[i] = 0;
int cnt = 0;
for(int i = 1; i <= n; i++)
if (a[x1][i] != a[x2][i]){
cnt++;
d[a[x1][i] - 'a']++;
d[a[x2][i] - 'a']--;
}
if (cnt > k)
return 0;
for(int i = 0; i < 26; i++)
if (d[i] != 0)
return 0;
return 1;
}
void solve(){
for(int x1 = 1; x1 <= n; x1++)
for(int x2 = x1 + 1; x2 <= n; x2++)
if (check(x1, x2)){
printf("DA");
return;
}
printf("NE");
}
int main(){
if (fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
readInput();
solve();
return 0;
}
Compilation message (stderr)
# | 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... |