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 FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define vv vector
#define ii pair<int,int>
using namespace std;
const int MAXN = 501;
char grid[MAXN][MAXN];
int compo[MAXN][26];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin >> n >> k;
FOR(i,n){
string s;cin >> s;
FOR(j,n)grid[i][j] = s[j],compo[i][s[j]-'a']++;
}
bool ok = 0;
FOR(i,n){
FOR(j,n){
if(i > j)continue;
bool b = 1;
FOR(a,26){
if(compo[i][a] != compo[j][a])b = 0;
}
if(!b)continue;
int ctr = 0;
FOR(a,n)ctr += grid[i][a] != grid[j][a];
if(ctr <= k)ok = 1;
}
}
if(ok)cout << "DA" << endl;
else cout << "NE" << endl;
return 0;
}
# | 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... |