Submission #218950

# Submission time Handle Problem Language Result Execution time Memory
218950 2020-04-03T09:01:59 Z quocnguyen1012 Ispit (COCI19_ispit) C++14
90 / 90
36 ms 896 KB
#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
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 512 KB Output is correct
2 Correct 5 ms 432 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 6 ms 896 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 13 ms 896 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 7 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 896 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 7 ms 896 KB Output is correct
4 Correct 6 ms 896 KB Output is correct