Submission details
Task:Monikulmio
Sender:insertNameHere
Submission time:2025-11-09 22:39:05 +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.01 s0details
#100.00 s0details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:48:25: warning: statement has no effect [-Wunused-value]
   48 |                 prevRow == rowsAndColumns[0].first;
      |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    string lines[n];
    for (int i = 0; i < n; i++)
    {
        lines[i] = string(m, '.');
    }

    pair<int, int> rowsAndColumns[k];

    int iter = 0;
    int x = 0;
    int y = 0;
    while (iter < k)
    {
        cin >> y >> x;
        rowsAndColumns[iter] = make_pair(y, x);
        lines[y].replace(x, 1, "*");
        int lineCount = 0;
        if (y == rowsAndColumns[iter - 1].first)
        {
            int prevCol = rowsAndColumns[iter - 1].second;
            if (x > prevCol)
            {
                lines[y].replace(prevCol + 1, x - prevCol - 1, string(x - prevCol - 1, '='));
            }
            else
            {
                lines[y].replace(x + 1, prevCol - 1, string(prevCol - 1, '='));
            }
            lineCount++;
        }

        if (x == rowsAndColumns[iter - 1].second || ((iter + 1 == k) && (x == rowsAndColumns[0].second)))
        {
            int prevRow = 0;
            if (x == rowsAndColumns[iter - 1].second)
            {
                prevRow = rowsAndColumns[iter - 1].first;
            }
            else
            {
                prevRow == rowsAndColumns[0].first;
            }
            // y is current row
            bool drawingFromBottomUp = prevRow < y;
            if (drawingFromBottomUp)
            {
                for (int i = y - 1; i > prevRow; i--)
                {
                    lines[i].replace(x, 1, "|");
                }
            }
            else
            {
                for (int i = prevRow + 1; i < y; i++)
                {
                    lines[i].replace(x, 1, "|");
                }
            }
            lineCount++;
        }

        if ((lineCount < 2) && (iter != 0))
        {
            // draw line between this and prev, fails on squares
            pair<int, int> prevCoords;
            if ((x != rowsAndColumns[iter - 1].second) && (y != rowsAndColumns[iter - 1].first))
            {
                prevCoords = rowsAndColumns[iter - 1];
            }
            else
            {
                prevCoords = rowsAndColumns[0];
            }

            if (prevCoords.first < y)
            {
                // if drawing from bottom to top
                if (prevCoords.second < x)
                {
                    // drawing right to left
                    for (int displacement = 1; y - displacement > prevCoords.first; displacement++)
                    {
                        lines[y - displacement].replace(x - displacement, 1, "\\");
                    }
                }
                else
                {
                    // drawing left to right
                    for (int displacement = 1; y - displacement > prevCoords.first; displacement++)
                    {
                        lines[y - displacement].replace(x + displacement, 1, "/");
                    }
                }
            }
            else
            {
                // drawing from top down
                if (prevCoords.second < x)
                {
                    // drawing right to left
                    for (int displacement = 1; y + displacement < prevCoords.first; displacement++)
                    {
                        lines[y + displacement].replace(x - displacement, 1, "\\");
                    }
                }
                else
                {
                    // drawing left to right
                    for (int displacement = 1; y + displacement > prevCoords.first; displacement++)
                    {
                        lines[y + displacement].replace(x + displacement, 1, "/");
                    }
                }
            }
        }
        iter++;
    }

        for (int i = 0; i < n; i++)
        {
        cout << lines[i] << "\n";
        }
}

Test details

Test 1 (public)

Verdict:

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

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

user output
.........
..|......
..|..*...
..|.\.\..
..|\...\.
...

Feedback: Incorrect character on row 2, col 3: expected '.', got '|'

Test 2 (public)

Verdict:

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

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

user output
.................................

Feedback: Incorrect character on row 2, col 11: expected '.', got '|'

Test 3 (public)

Verdict:

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

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

user output
.................................

Feedback: Incorrect character on row 3, col 30: expected '*', got '.'

Test 4 (public)

Verdict:

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

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

user output
.................................

Feedback: Incorrect character on row 2, col 13: expected '.', got '|'

Test 5 (public)

Verdict:

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

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

user output
.................................

Feedback: Incorrect character on row 3, col 20: expected '*', got '.'

Test 6 (public)

Verdict:

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

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

user output
.................................

Feedback: Incorrect character on row 2, col 3: expected '*', got '.'

Test 7 (public)

Verdict:

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

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

user output
(empty)

Error:
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Test 8 (public)

Verdict:

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

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

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 112)

Test 9 (public)

Verdict:

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

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

user output
(empty)

Error:
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::replace: __pos (which is 18446744073709551615) > this->size() (which is 100)

Test 10 (public)

Verdict:

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

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

user output
(empty)

Error:
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc