Submission details
Task:Monikulmio
Sender:lukarantalainen
Submission time:2026-06-05 19:40:34 +0300
Language:C++ (C++20)
Status:READY
Result:85
Feedback
subtaskverdictscore
#1ACCEPTED85
Test results
testverdicttimescore
#1ACCEPTED0.00 s10details
#2ACCEPTED0.00 s10details
#3ACCEPTED0.00 s10details
#4ACCEPTED0.00 s7details
#5ACCEPTED0.00 s10details
#6ACCEPTED0.00 s7details
#7ACCEPTED0.00 s7details
#8ACCEPTED0.00 s10details
#9ACCEPTED0.00 s7details
#10ACCEPTED0.01 s7details

Compiler report

input/code.cpp: In function 'void solution()':
input/code.cpp:96:22: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   96 |   for (size_t i{0}; i<k; ++i) {
      |                     ~^~
input/code.cpp:101:13: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (i+1 == k) {
      |         ~~~~^~~~

Code

#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <set>
#include <string>

enum Direction {
  N = '|',
  NE = '/',
  E = '=',
  SE = '\\',
  S = '|',
  SW = '/',
  W = '=',
  NW = '\\',
  NONE,
};

Direction chars_map[3][3] = {
  {NW, N, NE},
  {W, NONE, E},
  {SW, S, SE},
};

std::pair<int, int> getDir(const std::pair<int, int> &p1, const std::pair<int, int> &p2) {
  int dx {p2.first-p1.first};
  int dy {p2.second-p1.second};
  
  std::pair<int, int> v{
    (dx>0)-(dx<0),
    (dy>0)-(dy<0)
  };
  return v;
}

std::pair<int, int> operator+(const std::pair<int, int> &v1, const std::pair<int, int> &v2){
  return {v1.first+v2.first, v1.second+v2.second};
}

void operator+=(std::pair<int, int> &target, const std::pair<int, int> &add) {
  target = target+add;
}

void print(int n, int m, std::vector<std::vector<char>> map) {
  for (int i{}; i<n; ++i) {
    for (int j{}; j<m; ++j) {
      std::cout << map[i][j];
    }
    std::cout << "\n";
  }
}

std::vector<std::pair<int, int>> directions = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
std::set<char> boundaries {
  '|',
  '=',
  '/',
  '\\',
  '*',
  '#',
};

void flood(int n, int m, std::vector<std::vector<char>> &map, std::pair<int, int> node) {
  for (auto d : directions) {
    auto test = node+d;
    if (test.first < 0 || test.first >= n || test.second < 0 || test.second >= m) continue;
    if (!boundaries.count(map[test.first][test.second])) {
      map[test.first][test.second] = '#';
      flood(n, m, map, test);
    }
  }
  return;
}

void solution() {
  int n, m, k;
  std::cin >> n >> m >> k;

  std::vector<std::vector<char>> map(n, std::vector<char>(m, '.'));
  for (int i{}; i<n; ++i) {
    for (int j{}; j<m; ++j) {
      map[i][j] = '.';
    }
  }

  std::vector<std::pair<int, int>> coords;
  coords.resize(k);

  int x, y;
  for (int i{}; i<k; ++i) {
    std::cin >> x >> y;
    coords[i] = {x-1, y-1};
  }

  for (size_t i{0}; i<k; ++i) {
    
    std::pair<int, int> v1{};
    std::pair<int, int> v2{};
    
    if (i+1 == k) {
      v1 = {coords.back().first, coords.back().second};
      v2 = {coords[0].first, coords[0].second};
    } else {
      v1 = {coords[i].first, coords[i].second};
      v2 = {coords[i+1].first, coords[i+1].second};
    }

    std::pair<int, int> dir = getDir(v1, v2);
    char c = static_cast<char>(chars_map[dir.first+1][dir.second+1]);

    map[v1.first][v1.second] = '*';
    while (true) {
      v1 += dir;
      if (v1 == v2) {
        break;
      }
      map[v1.first][v1.second] = c;
    }
  }
  std::pair<int, int> p {n/2, m/2};
  flood(n, m, map, p);
  print(n, m, map);
}

int main() {
  solution();

  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
##############################...

Feedback: Lines are drawn correctly. Incorrect fill character on row 1, col 1: expected '.', got '#'

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
##############################...

Feedback: Lines are drawn correctly. Incorrect fill character on row 1, col 1: expected '.', got '#'

Test 7 (public)

Verdict: ACCEPTED

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

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

user output
##############################...

Feedback: Lines are drawn correctly. Incorrect fill character on row 1, col 1: expected '.', got '#'

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 2, col 11: 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 2, col 6: expected '#', got '.'