| Task: | Monikulmio |
| Sender: | dankke |
| Submission time: | 2025-11-07 23:08:45 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | 0 | details |
| #2 | WRONG ANSWER | 0.00 s | 0 | details |
| #3 | WRONG ANSWER | 0.00 s | 0 | details |
| #4 | WRONG ANSWER | 0.00 s | 0 | details |
| #5 | WRONG ANSWER | 0.00 s | 0 | details |
| #6 | WRONG ANSWER | 0.00 s | 0 | details |
| #7 | WRONG ANSWER | 0.00 s | 0 | details |
| #8 | WRONG ANSWER | 0.00 s | 0 | details |
| #9 | WRONG ANSWER | 0.00 s | 0 | details |
| #10 | WRONG ANSWER | 0.01 s | 0 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:190:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
190 | for (auto i = 0; i < corners.size(); i++)
| ~~^~~~~~~~~~~~~~~~Code
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <math.h>
#include <queue>
using namespace std;
float deltas_to_bearing(int dx, int dy)
{
dx = -dx;
if (dx == 0 and dy == 0)
{
return 0.0;
}
return atan2(dx, dy) + M_PI;
}
float normalize_bearing(float bearing)
{
if (bearing < 0.0)
{
int adjust_factor = floor(abs(bearing) / (2*M_PI)) + 1;
bearing += adjust_factor * 2 * M_PI;
}
if (bearing > 2*M_PI)
{
int adjust_factor = floor((bearing - 2 * M_PI) / (2*M_PI)) + 1;
bearing -= adjust_factor * 2 * M_PI;
}
return bearing;
}
vector<pair<int, int>> bearing_to_fill_deltas(float bearing)
{
vector<pair<int, int>> deltas;
const float PI_8 = M_PI / 8;
if (bearing < PI_8 + M_PI_4 || bearing > 2 * M_PI - M_PI_4 - PI_8)
{
deltas.push_back({-1, 0});
}
if (bearing > PI_8 && bearing < M_PI_4+ M_PI_2 + PI_8)
{
deltas.push_back({0, 1});
}
if (bearing > PI_8 + M_PI_2 && bearing < M_PI + M_PI_4 + PI_8)
{
deltas.push_back({1, 0});
}
if (bearing > PI_8 + M_PI && bearing < 2 * M_PI - PI_8)
{
deltas.push_back({0, -1});
}
return deltas;
}
int sgn(int val) {
if (val == 0)
{
return 0;
}
else if (val < 0)
{
return -1;
}
else
{
return 1;
}
}
int main() {
// Init variables
int n, m, k;
vector<string> board;
vector<vector<int>> corners;
cin >> n;
cin >> m;
cin >> k;
// get the corner coords
for (int i = 0; i < k; i++)
{
int x, y;
cin >> y;
cin >> x;
corners.push_back({y - 1, x - 1});
}
// create board
for (int i = 0; i < n; i++)
{
board.push_back("");
for (int j = 0; j < m; j++)
{
board[i] += ".";
}
}
// Draw corners and sides
vector<int> last_corner;
last_corner = corners.back();
vector<float> sides;
for (auto &¤t_corner : corners)
{
int y1, x1, y2, x2, dy, dx;
string side_char;
y1 = last_corner[0];
x1 = last_corner[1];
y2 = current_corner[0];
x2 = current_corner[1];
dy = y1 - y2;
dx = x1 - x2;
sides.push_back(deltas_to_bearing(dx, dy));
cout << sides.back() << "\n";
board[y1].replace(x1, 1, "*");
if (dy == 0)
{
side_char = "=";
}
else if (dx == 0)
{
side_char = "|";
}
else if (dx == dy)
{
side_char = "\\";
}
else
{
side_char = "/";
}
for (int i = 1; i < max(abs(dx), abs(dy)); i++)
{
int fy, fx;
fy = y2 + i * sgn(dy);
fx = x2 + i * sgn(dx);
board[fy].replace(fx, 1, side_char);
}
last_corner = current_corner;
}
float left_sum = 0, right_sum = 0;
float last_side = sides.back();
for (auto &&side : sides)
{
if (abs(last_side - M_PI) < 0.0001)
{
last_side = 0.0;
}
else if (last_side < M_PI)
{
last_side += M_PI;
}
else if (last_side > M_PI)
{
last_side -= M_PI;
}
float angle = normalize_bearing(last_side - side);
left_sum += angle;
right_sum += (2*M_PI - angle);
last_side = side;
}
float rotate_by;
if (left_sum < right_sum)
{
rotate_by = -M_PI_2;
}
else
{
rotate_by = M_PI_2;
}
queue<pair<int, int>> fill_positions;
last_corner = corners.back();
for (auto i = 0; i < corners.size(); i++)
{
vector<int> current_corner = corners[i];
float current_side = sides[i];
//cout << current_side << "\n";
current_side = normalize_bearing(current_side + rotate_by);
auto fill_deltas = bearing_to_fill_deltas(current_side);
int y1, x1, y2, x2, dy, dx, delta;
y1 = last_corner[0];
x1 = last_corner[1];
y2 = current_corner[0];
x2 = current_corner[1];
dy = y1 - y2;
dx = x1 - x2;
delta = max(abs(dx), abs(dy));
for (int j = 1; j < delta; j++)
{
int fy, fx;
fy = y2 + j * sgn(dy);
fx = x2 + j * sgn(dx);
for (auto && fill_delta : fill_deltas)
{
int y = fy + fill_delta.first;
int x = fx + fill_delta.second;
if (y >= n || y < 0 || x >= m || x < 0)
{
continue;
}
if (board[y].at(x) == '.')
{
fill_positions.push({y, x});
board[y].replace(x, 1, "#");
}
}
}
last_corner = current_corner;
}
vector<pair<int, int>> deltas = {
{0,1},
{1,0},
{-1,0},
{0,-1}
};
while (!fill_positions.empty())
{
auto [y, x] = fill_positions.front();
fill_positions.pop();
for (auto &&delta : deltas)
{
int dx, dy;
dy = y + delta.first;
dx = x + delta.second;
if (dy >= n || dy < 0 || dx >= m || dx < 0)
{
continue;
}
if (board[dy].at(dx) != '.')
{
continue;
}
fill_positions.push({dy, dx});
board[dy].replace(dx, 1, "#");
}
}
//print the board
for (int i = 0; i < n; i++)
{
cout << board[i] << "\n";
}
cout << endl;
return 0;
}Test details
Test 1 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 8 9 5 5 2 2 5 5 8 7 8 ... |
| correct output |
|---|
| ......... ....*.... .../#\... ../###\.. .*#####*. ... |
| user output |
|---|
| 3.14159 3.92699 5.49779 6.28319 1.5708 ... |
Feedback: Incorrect length on line 1: expected 9, got 7
Test 2 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 20 40 4 5 10 5 30 15 30 15 10 |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 3.14159 4.71239 6.28319 1.5708 ................................. |
Feedback: Incorrect length on line 1: expected 40, got 7
Test 3 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 20 40 29 8 7 13 2 14 2 9 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 1.5708 0.785398 6.28319 3.92699 6.28319 ... |
Feedback: Incorrect length on line 1: expected 40, got 6
Test 4 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 20 40 14 5 12 5 25 8 28 13 28 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 3.14159 4.71239 5.49779 6.28319 0.785398 ... |
Feedback: Incorrect length on line 1: expected 40, got 7
Test 5 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 20 40 12 3 20 7 16 7 9 11 13 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 2.35619 0.785398 1.5708 5.49779 0.785398 ... |
Feedback: Incorrect length on line 1: expected 40, got 7
Test 6 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 9 35 33 2 3 2 8 4 8 4 5 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 3.92699 4.71239 6.28319 1.5708 6.28319 ... |
Feedback: Incorrect length on line 1: expected 35, got 7
Test 7 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 30 100 69 6 10 6 14 7 14 7 18 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 3.92699 4.71239 6.28319 4.71239 6.28319 ... |
Feedback: Incorrect length on line 1: expected 100, got 7
Test 8 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 40 60 192 11 3 11 5 10 6 11 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| 2.35619 4.71239 3.92699 5.49779 4.71239 ... |
Feedback: Incorrect length on line 1: expected 60, got 7
Test 9 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 50 100 142 1 1 1 7 1 11 1 14 ... |
| correct output |
|---|
| *=====*===*==*................... |
| user output |
|---|
| 3.14159 4.71239 4.71239 4.71239 6.28319 ... |
Feedback: Incorrect length on line 1: expected 100, got 7
Test 10 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| 3.14159 3.92699 2.35619 4.71239 0.785398 ... |
Feedback: Incorrect length on line 1: expected 100, got 7
