| Task: | Monikulmio |
| Sender: | mestari037 |
| Submission time: | 2025-11-09 18:46:20 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 94 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 94 |
| test | verdict | time | score | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 10 | details |
| #2 | ACCEPTED | 0.00 s | 10 | details |
| #3 | ACCEPTED | 0.00 s | 10 | details |
| #4 | ACCEPTED | 0.00 s | 10 | details |
| #5 | ACCEPTED | 0.00 s | 10 | 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 | 7 | details |
| #10 | ACCEPTED | 0.00 s | 7 | details |
Code
#include <iostream>
#include <vector>
struct Piste {
int x;
int y;
};
int main(){
int n, m, k;
std::cin >> n >> m >> k;
std::vector<Piste> kärkiPisteet(k);
for (int i = 0; i < k; i++){
std::cin >> kärkiPisteet[i].y >> kärkiPisteet[i].x;
kärkiPisteet[i].x--;
kärkiPisteet[i].y--;
}
std::vector<std::vector<char>> ruudukko(n, std::vector<char>(m, '.'));
for (int i = 0; i < k; i++){
ruudukko[kärkiPisteet[i].y][kärkiPisteet[i].x] = '*';
}
for (int i = 0; i < k; i++){
Piste p1 = kärkiPisteet[i];
Piste p2 = kärkiPisteet[(i + 1) % k];
int dy = 0;
int dx = 0;
if (p2.y > p1.y) {
dy = 1;
} else if (p2.y < p1.y) {
dy = -1;
}
if (p2.x > p1.x) {
dx = 1;
} else if (p2.x < p1.x) {
dx = -1;
}
int y = p1.y;
int x = p1.x;
while (y != p2.y || x != p2.x){
if (ruudukko[y][x] != '*'){
if (dy == 0) {
ruudukko[y][x] = '=';
} else if (dx == 0) {
ruudukko[y][x] = '|';
} else if (dy == dx) {
ruudukko[y][x] = '\\';
} else {
ruudukko[y][x] = '/';
}
}
y += dy;
x += dx;
}
}
for (int i = 0; i < k; i++){
ruudukko[kärkiPisteet[i].y][kärkiPisteet[i].x] = '*';
}
std::vector<std::vector<char>> Ruudukko = ruudukko;
std::vector<std::pair<int, int>> xxx;
xxx.push_back({0, 0});
while (!xxx.empty()){
auto [y, x] = xxx.back();
xxx.pop_back();
if (y < 0 || y >= n || x < 0 || x >= m){
continue;
}
if (Ruudukko[y][x] != '.'){
continue;
}
Ruudukko[y][x] = 'O';
xxx.push_back({y - 1, x});
xxx.push_back({y + 1, x});
xxx.push_back({y, x - 1});
xxx.push_back({y, x + 1});
}
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (ruudukko[i][j] == '.' && Ruudukko[i][j] != 'O'){
ruudukko[i][j] = '#';
}
std::cout << ruudukko[i][j];
}
std::cout << "\n";
}
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 |
|---|
| ................................. |
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 |
|---|
| ................................. |
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 |
|---|
| *=====*===*==*################... |
Feedback: Lines are drawn correctly. Incorrect fill character on row 1, col 15: 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 1, col 10: expected '.', got '#'
