Submission #198856

# Submission time Handle Problem Language Result Execution time Memory
198856 2020-01-27T21:56:28 Z ZwariowanyMarcin Ispit (COCI19_ispit) C++14
90 / 90
37 ms 764 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;		

const int nax = 510;

int n, k;
char s[nax][nax];

void tak() {
	printf ("DA");
	exit(0);
}

void nie() {
	printf ("NE");
	exit(0);
}

int t[2][26];

int main() {		
	scanf ("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf ("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) {
			int l = 1;
			int r = n;
			while (l <= n && s[i][l] == s[j][l]) l++;
			while (1 <= r && s[i][r] == s[j][r]) r--;
			
			if (l == n) tak();
			
			if (r - l + 1 > k) continue;
			
			for (int j = 0; j < 2; ++j)
				for (int c = 0; c < 26; ++c)
					t[j][c] = 0;
			for (int k = l; k <= r; ++k) {
				t[0][s[i][k] - 'a']++;
				t[1][s[j][k] - 'a']++;
			}
			bool ok = 1;
			for (int c = 0; c < 26; ++c)
				if (t[0][c] != t[1][c]) ok = 0;
				
			if (ok) tak();
		}
	nie();
		
	
	return 0;
}

Compilation message

ispit.cpp: In function 'int main()':
ispit.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d%d", &n, &k);
  ~~~~~~^~~~~~~~~~~~~~~~
ispit.cpp:36:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%s", s[i] + 1);
   ~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 500 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 380 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 7 ms 740 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 19 ms 760 KB Output is correct
3 Correct 7 ms 760 KB Output is correct
4 Correct 9 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 6 ms 760 KB Output is correct
3 Correct 8 ms 760 KB Output is correct
4 Correct 6 ms 764 KB Output is correct