| Task: | Monikulmio |
| Sender: | viiviP |
| Submission time: | 2025-11-01 18:12:42 +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.01 s | 10 | details |
| #9 | ACCEPTED | 0.01 s | 7 | details |
| #10 | ACCEPTED | 0.01 s | 7 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:118:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
118 | if (yhtenainen == true && ((viereiset[{i, j}][0] == i && viereiset[{i, j}][1] == j-1)) || (viereiset[{i, j}][2] == i && viereiset[{i, j}][3] == j-1)) { //yhtenäisyys päättyy
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Code
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> r;
int n, m ,k;
void fill(int y, int x) {
if (r[y][x] == '.') {
return;
}
r[y][x] = '.';
if (x+1 < m && r[y][x+1] != '*' && r[y][x+1] != '|' && r[y][x+1] != '/' && r[y][x+1] != '\\' && r[y][x+1] != '=') {
fill(y, x+1);
}
if ( x-1 >= 0 && r[y][x-1] != '*' && r[y][x-1] != '|' && r[y][x-1] != '/' && r[y][x-1] != '\\' && r[y][x-1] != '=') {
fill(y, x-1);
}
if (y + 1 < n && r[y+1][x] != '*' && r[y+1][x] != '|' && r[y+1][x] != '/' && r[y+1][x] != '\\' && r[y+1][x] != '=') {
fill(y+1, x);
}
if (y- 1 >= 0 && r[y-1][x] != '*' && r[y-1][x] != '|' && r[y-1][x] != '/' && r[y-1][x] != '\\' && r[y-1][x] != '=') {
fill(y-1, x);
}
return;
}
int main() {
cin >> n>>m>>k;
vector<pair<int,int>> p(k);
//vector<pair<int, int>> reitti;
map<pair<int, int>, vector<int>> viereiset;
vector<int> rivit(n);
r.resize(n, vector<char>(m));
for (int y = 0; y<n;y++) {
for (int x = 0; x<m;x++) {
r[y][x] = '-';
}
}
for (int i = 0; i<k;i++) {
int y, x;
cin >> y>>x;
p[i] = {y-1, x-1};
r[y-1][x-1] = '*';
rivit[n] += 1;
}
int y = p[0].first;
int x = p[0].second;
p.push_back({y, x});
for (int i = 1; i<=k;i++) {
pair<int, int> kohde = p[i];
int x_lisa = 0;
int y_lisa = 0;
if (kohde.first < y) { //yläpuolella
y_lisa = -1;
}
else if (kohde.first > y) { //alapuolella
y_lisa = 1;
}
if (kohde.second < x) { //vasemmalla
x_lisa = -1;
}
else if (kohde.second > x) { //oikealle
x_lisa = 1;
}
x += x_lisa;
y += y_lisa;
while (x != kohde.second || y != kohde.first) {
//reitti.push_back({y, x});
viereiset[{y, x}].push_back(y-y_lisa);
viereiset[{y,x}].push_back(x-x_lisa);
viereiset[{y-y_lisa, x-x_lisa}].push_back(y);
viereiset[{y-y_lisa,x-x_lisa}].push_back(x);
if (x_lisa == 0 && (y_lisa == 1|| y_lisa == -1)) {
r[y][x] = '|';
} else if (y_lisa == 0 && (x_lisa == -1||x_lisa ==1)) {
r[y][x] = '=';
} else if ((x_lisa == 1 && y_lisa == 1)|| (x_lisa == -1 && y_lisa == -1)) {
r[y][x] = '\\';
} else if ((x_lisa == 1 && y_lisa == -1)|| (x_lisa == -1 && y_lisa == 1)) {
r[y][x] = '/';
}
x += x_lisa;
y += y_lisa;
}
viereiset[{y, x}].push_back(y-y_lisa);
viereiset[{y,x}].push_back(x-x_lisa);
viereiset[{y-y_lisa, x-x_lisa}].push_back(y);
viereiset[{y-y_lisa,x-x_lisa}].push_back(x);
}
//cout << viereiset[{7,6}][0]<<" "<<viereiset[{7,6}][1]<<"\n";
//cout << viereiset[{7,6}][2]<<" "<<viereiset[{7,6}][3]<<"\n";
bool sisalla = false;
int suunta = 0;
bool yhtenainen = false;
//cout <<"here1\n";
for (int i = 0; i<n;i++) {
for (int j = 0; j<m;j++) {
if (r[i][j] == '-') {
if (sisalla) {
r[i][j] = '#';
} else {
r[i][j] = '.';
}
} else if (r[i][j] == '|' || r[i][j] == '\\' || r[i][j] == '/') {
sisalla = !sisalla;
} else if (r[i][j] == '*' ) { //r[i][j] == '='
//if (i == 7 && j == 6) {
// cout << sisalla << " " << yhtenainen<<" \n";
//}
if (yhtenainen == true && ((viereiset[{i, j}][0] == i && viereiset[{i, j}][1] == j-1)) || (viereiset[{i, j}][2] == i && viereiset[{i, j}][3] == j-1)) { //yhtenäisyys päättyy
//määritä suunta, vasemmalle yhteys
//if (i == 7 && j == 6) {
// cout << "a: 1\n";
//}
if (viereiset[{i,j}][0] == i-1 || viereiset[{i,j}][2] == i-1) {
if (suunta != -1) {
sisalla = !sisalla;
}
suunta = 0;
} else if (viereiset[{i,j}][0] == i+1 || viereiset[{i,j}][2] == i+1) {
if (suunta != 1) {
sisalla = !sisalla;
}
suunta =0;
}
yhtenainen = false;
continue; //jatkaa suoraa
}
else if ((viereiset[{i, j}][0] == i+1 && viereiset[{i,j}] [2] == i+1) || (viereiset[{i, j}][0] == i-1 && viereiset[{i,j}] [2] == i-1)) { //kärki
//if (i == 7 && j == 6) {
// cout << "a: 2\n";
//}
continue;
}
else if (viereiset[{i,j}][0] != i && viereiset[{i,j}][2] != i) { //seinämäkulma
sisalla = !sisalla;
//if (i == 7 && j == 6) {
// cout << "a: 3\n";
// cout << viereiset[{7,6}][0]<<" "<<viereiset[{7,6}][1]<<"\n";
// cout << viereiset[{7,6}][2]<<" "<<viereiset[{7,6}][3]<<"\n";
//
//}
continue;
}
else if ((viereiset[{i, j}][0] == i && viereiset[{i, j}][1] == j+1) || (viereiset[{i, j}][2] == i && viereiset[{i, j}][3] == j+1)) { //suora alkaa
//if (i == 7 && j == 6) {
// cout << "a: 4\n";
//}
yhtenainen = true;
//cout << "suora aloitettu "<< i<<" "<<j<<"\n";
//määritä alkava suunta
if (viereiset[{i,j}][0] == i+1 || viereiset[{i,j}][2] == i+1) {
suunta = 1;
} else if (viereiset[{i,j}][0] == i-1 || viereiset[{i,j}][2] == i-1) {
suunta = -1;
}
//cout << "suunta: "<<suunta<<"\n";
}
else { // =*=
//if (i == 7 && j == 6) {
// cout << "a: 5\n";
//}
yhtenainen = true;
//sisalla = !sisalla;
}
}
// = ei tee mitttään
}
yhtenainen = false;
sisalla = false;
}
for (int y = 0;y<n; y++) {
for (int x =0;x<m;x++) {
cout << r[y][x];
}
cout << "\n";
}
}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 12, col 84: 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 8, col 71: expected '#', got '.'
