Submission #482820

# Submission time Handle Problem Language Result Execution time Memory
482820 2021-10-26T13:07:10 Z rainboy Crtanje (COCI20_crtanje) C
50 / 50
0 ms 204 KB
#include <stdio.h>
#include <string.h>

#define N	100

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
	static char cc[N + 1], aa[N + 1][N + 1];
	int n, i, x, mn, mx;

	scanf("%d%s", &n, cc);
	x = mn = mx = 0;
	for (i = 0; i < n; i++)
		if (cc[i] == '+')
			mx = max(mx, ++x);
		else if (cc[i] == '-')
			mn = min(mn, --x);
		else
			mx = max(mx, x + 1);
	x = 0;
	for (i = 0; i < mx - mn; i++)
		memset(aa[i], '.', n * sizeof *aa[i]);
	for (i = 0; i < n; i++)
		if (cc[i] == '+')
			aa[mx - ++x][i] = '/';
		else if (cc[i] == '-')
			aa[mx - x--][i] = '\\';
		else
			aa[mx - (x + 1)][i] = '_';
	for (i = 0; i < mx - mn; i++)
		printf("%s\n", aa[i]);
	return 0;
}

Compilation message

crtanje.c: In function 'main':
crtanje.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%s", &n, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct