cses

cses solutions in pure c
git clone git://git.superpozycja.net/cses
log | files | refs

s.c (627B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 #include <string.h>
      4 #include <stdint.h>
      5 
      6 int solve()
      7 {
      8 	int n, m;
      9 	int i, j;
     10 	int x;
     11 
     12 	scanf("%d %d\n", &n, &m);
     13 
     14 	int a[n + 1][m + 1];
     15 
     16 	memset(a, 0, sizeof(a));
     17 
     18 	int res[n][m];
     19 
     20 	for (i = 1; i < n + 1; i++) {
     21 		for (j = 1; j < m + 1; j++) {
     22 			a[i][j] = getchar();
     23 			for (x = 'A'; x <= 'D'; x++)
     24 				if (x != a[i][j] && x != res[i-2][j-1] && x != res[i-1][j-2])
     25 					break;
     26 			res[i-1][j-1] = x;
     27 		}
     28 
     29 		getchar();
     30 	}
     31 
     32 	for (i = 0; i < n; i++) {
     33 		for (j = 0; j < m; j++)
     34 			printf("%c", res[i][j]);
     35 		printf("\n");
     36 	}
     37 
     38 	return 0;
     39 }
     40 
     41 int main()
     42 {
     43 	int t = 1;
     44 	while (t--)
     45 		solve();
     46 }