| Task: | Monikulmio |
| Sender: | rendes |
| Submission time: | 2025-10-27 19:19:12 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 10 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 10 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | details |
| #2 | WRONG ANSWER | 0.00 s | 0 | details |
| #3 | RUNTIME ERROR | 0.00 s | 0 | details |
| #4 | RUNTIME ERROR | 0.00 s | 0 | details |
| #5 | WRONG ANSWER | 0.00 s | 0 | details |
| #6 | RUNTIME ERROR | 0.00 s | 0 | details |
| #7 | RUNTIME ERROR | 0.00 s | 0 | details |
| #8 | RUNTIME ERROR | 0.00 s | 0 | details |
| #9 | RUNTIME ERROR | 0.00 s | 0 | details |
| #10 | RUNTIME ERROR | 0.00 s | 0 | details |
Compiler report
input/code.cpp: In function 'void getNums(std::string, int**, uint)':
input/code.cpp:20:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | for (int i = 0; in.length() > i; i++) {
| ~~~~~~~~~~~~^~~
input/code.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | if (in[i] == ' ' || i == in.length() - 1) {
| ~~^~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:141: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]
141 | std::memset(poss, 0, size * sizeof(ivec2));
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cp...Code
#include <cstdlib>
#include <cstring>
#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));
auto print = [&]() {
// print
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
std::cout << grid[y * h + x];
}
std::cout << "\n";
}
};
for (int pc = 0; pc < n; pc++) {
grid[points[pc].y * h + points[pc].x] = char('*');
ivec2 tp = points[pc];
ivec2 lp = pc == 0 ? points[n - 1] : points[pc - 1];
// 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 * h + x] = '=';
}
} else if (tp.x == lp.x) // draw vertical line
{
int diff = (tp.y - lp.y < 0 ? 1 : -1);
for (int y = tp.y + diff; y != lp.y; y += diff) {
grid[y * h + 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));
for (int l = 1; l < std::abs(tp.x - lp.x); l++) {
ivec2 cp = tp + diff * l;
grid[cp.y * h + cp.x] = diff.x * diff.y < 0 ? '/' : '\\';
}
}
}
// fill insides ¬‿¬
ivec2 startpos[3];
int done = 0;
for (int pc = 0; pc < n; pc++) { // duct tape and prayers please
startpos[done] = points[pc];
done++;
if (done == 3) {
if (startpos[0].x + startpos[1].x ==
startpos[2].x / 2) // if they're all the same
done--; // find some other
else if (startpos[0].y + startpos[1].y ==
startpos[2].y / 2) // if they're all the same
done--; // find some other
}
}
startpos[0] = (startpos[0] + startpos[1] + startpos[2]) / 3;
#define GET(x, y) grid[y * h + x]
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));
};
// recurse
fill(startpos[0]);
print();
}
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: WRONG ANSWER
| input |
|---|
| 20 40 4 5 10 5 30 15 30 15 10 |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ................................. |
Feedback: Incorrect character on row 4, col 30: expected '.', got '*'
Test 3 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 29 8 7 13 2 14 2 9 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Error:
*** stack smashing detected ***: terminated
Test 4 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 20 40 14 5 12 5 25 8 28 13 28 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Error:
*** stack smashing detected ***: terminated
Test 5 (public)
Verdict: WRONG ANSWER
| input |
|---|
| 20 40 12 3 20 7 16 7 9 11 13 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| ##############################... |
Feedback: Incorrect character on row 2, col 40: expected '.', got '*'
Test 6 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 9 35 33 2 3 2 8 4 8 4 5 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Error:
*** stack smashing detected ***: terminated
Test 7 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 30 100 69 6 10 6 14 7 14 7 18 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Error:
*** stack smashing detected ***: terminated
Test 8 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 40 60 192 11 3 11 5 10 6 11 7 ... |
| correct output |
|---|
| ................................. |
| user output |
|---|
| (empty) |
Test 9 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 50 100 142 1 1 1 7 1 11 1 14 ... |
| correct output |
|---|
| *=====*===*==*................... |
| user output |
|---|
| *=====*===*==*................... |
Error:
*** stack smashing detected ***: terminated
Test 10 (public)
Verdict: RUNTIME ERROR
| input |
|---|
| 100 100 1000 10 1 4 7 1 4 1 9 ... |
| correct output |
|---|
| ...*====*........................ |
| user output |
|---|
| (empty) |
