| Task: | Monikulmio |
| Sender: | rendes |
| Submission time: | 2025-10-28 12:48:20 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 91 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 91 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | details |
| #2 | ACCEPTED | 0.00 s | 10 | details |
| #3 | ACCEPTED | 0.00 s | 7 | details |
| #4 | ACCEPTED | 0.00 s | 10 | details |
| #5 | ACCEPTED | 0.00 s | 7 | 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 | 10 | details |
| #10 | ACCEPTED | 0.00 s | 7 | details |
Compiler report
input/code.cpp: In function 'void getNums(std::string, int**, uint)':
input/code.cpp:21:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
21 | for (int i = 0; in.length() > i; i++) {
| ~~~~~~~~~~~~^~~
input/code.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if (in[i] == ' ' || i == in.length() - 1) {
| ~~^~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:194:14: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct ivec2'; use assignment or value-initialization instead [-Wclass-memaccess]
194 | std::memset(poss, 0, size * sizeof(ivec2));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cp...Code
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <string>
#include <sys/types.h>
#include <vector>
std::string getString() {
std::string line;
std::getline(std::cin, line);
return line;
}
// in: input string. values: raw array of values in reverse order, vcount:
// amount of values in the raw array
void getNums(const std::string in, int **values,
uint vcount) { // reverse order lmao
uint lastIndex = 0;
for (int i = 0; in.length() > i; i++) {
if (in[i] == ' ' || i == in.length() - 1) {
vcount--;
*values[vcount] = std::stoi(in.substr(lastIndex, i));
lastIndex = i;
}
}
}
struct ivec2 {
int x, y = 0;
ivec2(int x, int y) : x(x), y(y) {}
ivec2() {}
ivec2 operator+(const ivec2 &other) const {
return ivec2(x + other.x, y + other.y);
}
ivec2 operator*(const int &value) const {
return ivec2(x * value, y * value);
}
ivec2 operator/(const int &value) const {
return ivec2(x / value, y / value);
}
};
void printpgon(int w, int h, int n, ivec2 *points) {
// create
const size_t size = static_cast<size_t>(w * h);
char *grid = new char[size]; // n could surely never be 0 :)
std::memset(grid, '.', size * sizeof(char));
#define GET(x, y) grid[y * w + x]
auto print = [&]() {
// print
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
if (GET(x, y) != 'E' && GET(x, y) != 'A' &&
GET(x, y) != 'Y') // annyoing
std::cout << grid[y * w + x];
else
std::cout << '*';
}
std::cout << "\n";
}
};
// process
for (int pc = 0; pc < n; pc++) {
grid[points[pc].y * w + points[pc].x] = char('*');
ivec2 tp = points[pc];
ivec2 lp = pc == 0 ? points[n - 1] : points[pc - 1];
ivec2 np = pc == n - 1 ? points[0] : points[pc + 1];
bool was = false;
if (GET(lp.x, lp.y) == 'E')
was = true;
;
// draw horizontal line
if (tp.y == lp.y) {
int diff = (tp.x - lp.x < 0 ? 1 : -1);
for (int x = tp.x + diff; x != lp.x; x += diff) {
grid[tp.y * w + x] = '=';
}
} else if (tp.x == lp.x) // draw vertical line
{
int diff = (tp.y - lp.y < 0 ? 1 : -1);
GET(tp.x, tp.y) = diff < 0 ? 'Y' : 'A';
GET(lp.x, lp.y) = diff < 0 ? 'A' : 'Y';
for (int y = tp.y + diff; y != lp.y; y += diff) {
grid[y * w + tp.x] = '|';
}
} else // draw diagonal line that is surely 45\deg
{
ivec2 diff((tp.x - lp.x < 0 ? 1 : -1), (tp.y - lp.y < 0 ? 1 : -1));
GET(tp.x, tp.y) = diff.y < 0 ? 'Y' : 'A';
GET(lp.x, lp.y) = diff.y < 0 ? 'A' : 'Y';
for (int l = 1; l < std::abs(tp.x - lp.x); l++) {
ivec2 cp = tp + diff * l;
grid[cp.y * w + cp.x] = diff.x * diff.y < 0 ? '/' : '\\';
}
}
if (np.y == lp.y) { // we are on a star edge D:
GET(tp.x, tp.y) = 'E';
}
if (was) {
GET(lp.x, lp.y) = 'E';
}
}
auto cheats = [&](ivec2 candidate) {
if (candidate.x == 0 || candidate.x == w - 1)
return false;
else if (GET(candidate.x - 1, candidate.y) == '=' &&
GET(candidate.x + 1, candidate.y) == '=')
return true;
else
return false;
};
// fill insides ¬‿¬
std::vector<uint> ps;
for (int y = 0; y < h; y++) {
bool flag = false; // coloring
char last = 'B'; // B.
for (int x = 0; x < w; x++) {
if (GET(x, y) != '.') {
if (GET(x, y) == 'A' || GET(x, y) == 'Y') {
flag = !flag;
if (last == 'B') {
last = GET(x, y);
} else {
if (last != GET(x, y))
flag = !flag;
last = 'B';
}
} else if (((GET(x, y) == '*' || GET(x, y) == '|') ||
GET(x, y) == '/' || GET(x, y) == '\\') &&
!cheats({x, y})) {
if (last != 'B')
last = 'B';
flag = !flag;
}
} else if (GET(x, y) == '.') {
if (flag)
GET(x, y) = '#';
last = 'B';
}
}
}
std::function<void(ivec2)> fill;
fill = [&](ivec2 pos) {
if (GET(pos.x, pos.y) != '.')
return;
GET(pos.x, pos.y) = '#';
// print();
fill(ivec2(pos.x + 1, pos.y));
fill(ivec2(pos.x - 1, pos.y));
fill(ivec2(pos.x, pos.y + 1));
fill(ivec2(pos.x, pos.y - 1));
};
// GET(startpos.x, startpos.y)='M';
// recurse
// fill(startpos);
print();
delete[] grid;
}
int main() {
int w, h, n;
int **vals = new int *[3];
vals[2] = &h;
vals[1] = &w;
vals[0] = &n;
getNums(getString(), vals, 3);
ivec2 *poss; // raw array but still uses string smh
const size_t size = static_cast<size_t>(n);
poss = new ivec2[size]; // n could surely never be 0 :)
std::memset(poss, 0, size * sizeof(ivec2));
int x, y;
vals[0] = &x;
vals[1] = &y;
for (int i = 0; i < n; i++) {
getNums(getString(), vals, 2);
poss[i] = ivec2(x - 1, y - 1);
}
printpgon(w, h, n, poss);
// doesnt matter but why not
delete[] poss;
delete[] vals;
}
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 |
|---|
| ................................. |
Feedback: Lines are drawn correctly. Incorrect fill character on row 3, col 31: expected '.', got '#'
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 |
|---|
| ................................. |
Feedback: Lines are drawn correctly. Incorrect fill character on row 7, col 32: expected '.', got '#'
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 |
|---|
| *=====*===*==*................... |
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 39: expected '.', got '#'
