Submission details
Task:Monikulmio
Sender:Jonde
Submission time:2025-10-27 17:48:18 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details
#20.00 s0details
#30.00 s0details
#40.00 s0details
#50.00 s0details
#60.00 s0details
#70.00 s0details
#80.00 s0details
#90.00 s0details
#100.00 s0details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:25:12: warning: 'last_y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |     } else if (x < x2) {
      |            ^~
input/code.cpp:62:17: note: 'last_y' was declared here
   62 |     int last_x, last_y;
      |                 ^~~~~~
input/code.cpp:15:12: warning: 'last_x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |     } else if (x < x2) {
      |            ^~
input/code.cpp:62:9: note: 'last_x' was declared here
   62 |     int last_x, last_y;
      |         ^~~~~~
input/code.cpp:25:12: warning: 'first_y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |     } else if (x < x2) {
      |            ^~
input/code.cpp:61:18: note: 'first_y' was declared here
   61 |     int first_x, first_y;
      |                  ^~~~~~~
input/code.cpp:15:12: warning: 'first_x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |     }...

Code

#include <iostream>
#include <vector>
using namespace std;

int h, w, k;

int coord_to_index(int x, int y) {
    return (y - 1) * w + x - 1;
}

//coord1 compared to coord2
int get_delta_x(int x, int x2) {
    if (x > x2) {
        return 1;
    } else if (x < x2) {
        return -1;
    } else {
        return 0;
    }
}

int get_delta_y(int x, int x2) {
    if (x > x2) {
        return 1;
    } else if (x < x2) {
        return -1;
    } else {
        return 0;
    }
}

char get_char(int delta_x, int delta_y) {
    if ((delta_x > 0 && delta_y < 0) || (delta_x < 0 && delta_y > 0)) {
        return '/';
    } else if ((delta_x > 0 && delta_y > 0) || (delta_x < 0 && delta_y < 0)) {
        return '\\';
    } else if (delta_x == 0) {
        return '|';
    } else if (delta_y == 0) {
        return '=';
    } else {
        return 'e';
    }
}

void print_result(vector<char> s) {
    for (int i = 0; i < h * w; i++){
        if (i % w == 0) {
            cout << '\n';
        }
        cout << s[i];
    }
}

int main() {
    cin >> h >> w >> k;
    vector<char> shape(h * w, '.');

    //print_result(shape);

    int first_x, first_y;
    int last_x, last_y;

    for (int i = 0; i < k; i++) {
        int x, y;
        cin >> y >> x;

        int current_index = coord_to_index(x, y);
        shape[current_index] = '*';

        //print_result(shape);

        if (!first_x) {
            first_x = x, first_y = y;
            last_x = x, last_y = y;
            continue;
        }
        int delta_x, delta_y;

        //cout << x << " " << last_x << " " << y << " " << last_y << "\n";
        delta_x = get_delta_x(x, last_x), delta_y = get_delta_y(y, last_y);

        //cout << delta_x << " " << delta_y << "\n";

        char ch = get_char(delta_x, delta_y);
        //cout << ch << "\n";

        int loop_coord_x = last_x, loop_coord_y = last_y;
        loop_coord_x += delta_x, loop_coord_y += delta_y;
        
        while (true) {
            if (loop_coord_x == x && loop_coord_y == y) {
                break;
            }
            //cout << loop_coord_x << " " << loop_coord_y << " " << coord_to_index(loop_coord_x, loop_coord_y) << "\n";
            shape[coord_to_index(loop_coord_x, loop_coord_y)] = ch;
            loop_coord_x += delta_x, loop_coord_y += delta_y;
        }
        last_x = x;
        last_y = y;
    
    }
    int delta_x = get_delta_x(first_x, last_x), delta_y = get_delta_y(first_y, last_y);
    char ch = get_char(delta_x, delta_y);
    int loop_coord_x = last_x, loop_coord_y = last_y;
    loop_coord_x += delta_x, loop_coord_y += delta_y;
    while (true) {
        if (loop_coord_x == first_x && loop_coord_y == first_y) {
            break;
        }
        //cout << loop_coord_x << " " << loop_coord_y << " " << coord_to_index(loop_coord_x, loop_coord_y) << "\n";
        shape[coord_to_index(loop_coord_x, loop_coord_y)] = ch;
        loop_coord_x += delta_x, loop_coord_y += delta_y;
    }
    

    print_result(shape);
}

Test details

Test 1 (public)

Verdict:

input
8 9 5
5 2
2 5
5 8
7 8
...

correct output
.........
....*....
.../#\...
../###\..
.*#####*.
...

user output
(empty)

Test 2 (public)

Verdict:

input
20 40 4
5 10
5 30
15 30
15 10

correct output
.................................

user output
(empty)

Test 3 (public)

Verdict:

input
20 40 29
8 7
13 2
14 2
9 7
...

correct output
.................................

user output
(empty)

Test 4 (public)

Verdict:

input
20 40 14
5 12
5 25
8 28
13 28
...

correct output
.................................

user output
(empty)

Test 5 (public)

Verdict:

input
20 40 12
3 20
7 16
7 9
11 13
...

correct output
.................................

user output
(empty)

Test 6 (public)

Verdict:

input
9 35 33
2 3
2 8
4 8
4 5
...

correct output
.................................

user output
(empty)

Test 7 (public)

Verdict:

input
30 100 69
6 10
6 14
7 14
7 18
...

correct output
.................................

user output
(empty)

Test 8 (public)

Verdict:

input
40 60 192
11 3
11 5
10 6
11 7
...

correct output
.................................

user output
(empty)

Test 9 (public)

Verdict:

input
50 100 142
1 1
1 7
1 11
1 14
...

correct output
*=====*===*==*...................

user output
(empty)

Test 10 (public)

Verdict:

input
100 100 1000
10 1
4 7
1 4
1 9
...

correct output
...*====*........................

user output
(empty)