| Task: | Monikulmio |
| Sender: | Lily2 |
| Submission time: | 2025-11-02 19:55:50 +0200 |
| Language: | C |
| Status: | READY |
| Result: | 94 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 94 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | details |
| #2 | ACCEPTED | 0.00 s | 10 | details |
| #3 | ACCEPTED | 0.00 s | 10 | details |
| #4 | ACCEPTED | 0.00 s | 10 | details |
| #5 | ACCEPTED | 0.00 s | 10 | details |
| #6 | ACCEPTED | 0.00 s | 10 | details |
| #7 | ACCEPTED | 0.00 s | 10 | details |
| #8 | ACCEPTED | 0.00 s | 10 | details |
| #9 | ACCEPTED | 0.00 s | 7 | details |
| #10 | ACCEPTED | 0.00 s | 7 | details |
Compiler report
input/code.c: In function 'main':
input/code.c:35:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%d %d %d", &n, &m, &k);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.c:40:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d %d", &y, &x);
| ^~~~~~~~~~~~~~~~~~~~~~Code
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int y;
int x;
} Pt;
static int sgn(int v) {
if (v > 0)
return 1;
if (v < 0)
return -1;
return 0;
}
static int max(int a, int b) { return a > b ? a : b; }
static void try_push(int y, int x, int n, int m, char **g, char **vis, int *qy,
int *qx, int *tail) {
if (y < 0 || y >= n || x < 0 || x >= m)
return;
if (vis[y][x])
return;
if (g[y][x] != '.')
return;
vis[y][x] = 1;
qy[*tail] = y;
qx[*tail] = x;
(*tail)++;
}
int main(void) {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
Pt *p = (Pt *)malloc(sizeof(Pt) * k);
for (int i = 0; i < k; i++) {
int y, x;
scanf("%d %d", &y, &x);
p[i].y = y - 1;
p[i].x = x - 1;
}
char **g = (char **)malloc(n * sizeof(*g));
for (int i = 0; i < n; i++) {
g[i] = (char*) malloc(m * sizeof(**g));
for (int j = 0; j < m; j++)
g[i][j] = '.';
}
// MARK: Draw Edges
for (int i = 0; i < k; i++) {
Pt a = p[i];
Pt b = p[(i + 1) % k];
int dy = sgn(b.y - a.y);
int dx = sgn(b.x - a.x);
int steps = max(abs(b.y - a.y), abs(b.x - a.x));
char ec;
if (dy == 0)
ec = '=';
else if (dx == 0)
ec = '|';
else if (dx * dy < 0)
ec = '/';
else
ec = '\\';
for (int j = 0; j < steps; j++) {
int y = a.y + j * dy;
int x = a.x + j * dx;
g[y][x] = ec;
}
}
// MARK: Draw Cornerss
for (int i = 0; i < k; i++) {
int y = p[i].y;
int x = p[i].x;
if (y >= 0 && y < n && x >= 0 && x < m)
g[y][x] = '*';
}
// MARK: Fill Outside
int cap = n * m;
int *qy = (int *)malloc(cap * sizeof(int));
int *qx = (int *)malloc(cap * sizeof(int));
char **vis = (char **)malloc(n * sizeof(*vis));
for (int i = 0; i < n; i++)
vis[i] = (char *)calloc(m, 1);
int head = 0, tail = 0;
for (int x = 0; x < m; x++) {
try_push(0, x, n, m, g, vis, qy, qx, &tail);
try_push(n - 1, x, n, m, g, vis, qy, qx, &tail);
}
for (int y = 0; y < n; y++) {
try_push(y, 0, n, m, g, vis, qy, qx, &tail);
try_push(y, m - 1, n, m, g, vis, qy, qx, &tail);
}
const int dy[4] = {-1, 1, 0, 0};
const int dx[4] = {0, 0, -1, 1};
while (head < tail) {
int y = qy[head];
int x = qx[head];
head++;
for (int d = 0; d < 4; d++) {
int ny = y + dy[d];
int nx = x + dx[d];
try_push(ny, nx, n, m, g, vis, qy, qx, &tail);
}
}
// MARK: Fill Inside
for (int y = 0; y < n; y++) {
for (int x = 0; x < m; x++) {
if (g[y][x] == '.' && !vis[y][x])
g[y][x] = '#';
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
putchar(g[i][j]);
putchar('\n');
}
return 0;
}
Test details
Test 1 (public)
Verdict: ACCEPTED
| input |
|---|
| 8 9 5 5 2 2 5 5 8 7 8 ... |
| correct output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
| user output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
Test 2 (public)
Verdict: ACCEPTED
| input |
|---|
| 20 40 4 5 10 5 30 15 30 15 10 |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 3 (public)
Verdict: ACCEPTED
| input |
|---|
| 20 40 29 8 7 13 2 14 2 9 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 4 (public)
Verdict: ACCEPTED
| input |
|---|
| 20 40 14 5 12 5 25 8 28 13 28 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 5 (public)
Verdict: ACCEPTED
| input |
|---|
| 20 40 12 3 20 7 16 7 9 11 13 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 6 (public)
Verdict: ACCEPTED
| input |
|---|
| 9 35 33 2 3 2 8 4 8 4 5 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 7 (public)
Verdict: ACCEPTED
| input |
|---|
| 30 100 69 6 10 6 14 7 14 7 18 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 8 (public)
Verdict: ACCEPTED
| input |
|---|
| 40 60 192 11 3 11 5 10 6 11 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Test 9 (public)
Verdict: ACCEPTED
| input |
|---|
| 50 100 142 1 1 1 7 1 11 1 14 ... |
| correct output |
|---|
| *=====*===*==*................... |
| user output |
|---|
| *=====*===*==*................... |
Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 9: expected '.', got '#'
Test 10 (public)
Verdict: ACCEPTED
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| ...*====*........................ |
Feedback: Lines are drawn correctly. Incorrect fill character on row 4, col 29: expected '.', got '#'
