| Task: | Hypyt |
| Sender: | rendes |
| Submission time: | 2025-10-31 09:08:21 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | 30 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 10 |
| #2 | ACCEPTED | 20 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| #4 | TIME LIMIT EXCEEDED | 0 |
| #5 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #2 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #3 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #4 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #5 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #6 | ACCEPTED | 0.02 s | 2, 5 | details |
| #7 | ACCEPTED | 0.02 s | 2, 5 | details |
| #8 | ACCEPTED | 0.03 s | 2, 5 | details |
| #9 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #10 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #11 | TIME LIMIT EXCEEDED | -- | 3, 4, 5 | details |
| #12 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #13 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 4, 5 | details |
| #15 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #16 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #17 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #18 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #19 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #20 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #21 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #22 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #23 | ACCEPTED | 0.00 s | 1, 2, 3, 4, 5 | details |
| #24 | ACCEPTED | 0.48 s | 5 | details |
| #25 | ACCEPTED | 0.48 s | 5 | details |
| #26 | TIME LIMIT EXCEEDED | -- | 5 | details |
| #27 | ACCEPTED | 0.51 s | 5 | details |
Compiler report
input/code.cpp: In function 'void getNums(std::string, int**, uint)':
input/code.cpp:16:41: warning: comparison of integer expressions of different signedness: 'uint' {aka 'unsigned int'} and 'int' [-Wsign-compare]
16 | while (getline(iss, s, ' ') && vcount != ccount) {
| ~~~~~~~^~~~~~~~~
input/code.cpp: In member function 'void Grid::drawco(uint, uint16_t)':
input/code.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'uint' {aka 'unsigned int'} [-Wsign-compare]
60 | for (int i = 0; i < h; i++) {
| ~~^~~
input/code.cpp: In member function 'void Grid::drawro(uint, uint16_t)':
input/code.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'uint' {aka 'unsigned int'} [-Wsign-compare]
67 | for (int i = 0; i < w; i++) {
| ~~^~~
input/code.cpp: In member function 'void Grid::print()':
input/code.cpp:73:23: w...Code
#include <cstdint>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <sys/types.h>
#include <unordered_set>
#define MONS 65535
#define UNIN 65534
void getNums(const std::string in, int **values, uint vcount) {
int ccount = 0;
std::istringstream iss(in);
std::string s;
while (getline(iss, s, ' ') && vcount != ccount) {
*values[ccount] = std::stoi(s);
ccount++;
}
}
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);
}
};
struct Grid {
uint16_t *cgrid;
uint w, h;
uint16_t monster = MONS; // holy hell
Grid(uint iw, uint ih) {
w = iw;
h = ih;
cgrid = new uint16_t[w * h];
// std::memset(cgrid, 0, w * h * sizeof(uint));
};
inline uint16_t &getc(uint x, uint y) {
if (x >= w || x < 0 || y >= h || y < 0) {
return monster;
std::cout << "rejected: " << x << y << " \n";
}
return cgrid[y * w + x];
}
void setc(uint x, uint y, uint16_t c) { getc(x, y) = c; }
void drawco(uint x, uint16_t c) {
for (int i = 0; i < h; i++) {
setc(x, i, c);
}
}
inline uint16_t getIndex(uint16_t x, uint16_t y) { return y * w + x; }
inline ivec2 getCoords(uint16_t index) { return ivec2(index % w, index / w); }
void drawro(uint y, uint16_t c) {
for (int i = 0; i < w; i++) {
setc(i, y, c);
}
}
void print() {
for (int y = 0; y < h; y++) {
int charLen = 0;
std::cout << "|";
for (int x = 0; x < w; x++) {
std::cout << getc(x, y);
int numLen = std::to_string(getc(x, y)).size();
std::cout << std::string(5 - numLen, ' ');
std::cout << "|";
charLen += 6;
}
std::cout << "\n";
for (int x = 0; x < charLen; x++) {
std::cout << "-";
}
std::cout << "\n";
}
std::cout << "\n";
}
int solve(uint16_t sx, uint16_t sy, uint16_t dx, uint16_t dy) { // idk what is going on in here. its so tupid
std::unordered_set<uint16_t> visited;
std::unordered_set<uint16_t> options;
options.insert(getIndex(dx, dy));
visited.insert(getIndex(dx, dy));
int step = 0;
if (dx == sx && dy == sy)
return 0;
else if (dx == sx || dy == sy)
return 1;
while (options.size() != 0) {
step++;
//std::cout << "step: " << step << "\n";
std::unordered_set<uint16_t> indices = std::move(options);
for (auto index : indices) {
ivec2 cpos = getCoords(index);
//std::cout << "pos: " << cpos.x << " " << cpos.y << " " << index << "\n";
for (int x = 0; x < w; x++) { // add row into road
if (!indices.count(getIndex(x, cpos.y)) && getc(x, cpos.y) == UNIN &&
!visited.count(getIndex(x, cpos.y))) {
if (x == sx || cpos.y == sy) { // can we move into road?
return step + 1;
}
options.insert(getIndex(x, cpos.y));
visited.insert(getIndex(x, cpos.y));
}
}
for (int y = 0; y < w; y++) { // add row into road
if (!indices.count(getIndex(cpos.x, y)) && getc(cpos.x, y) == UNIN &&
!visited.count(getIndex(cpos.x, y))) {
if (cpos.x == sx || y == sy) { // can we move into road?
return step+1;
}
options.insert(getIndex(cpos.x, y));
visited.insert(getIndex(cpos.x, y));
}
}
}
// nothing :(
}
return -1;
}
};
int main() {
int w, h, c, z;
int **vals;
vals = new int *[4];
vals[0] = &h;
vals[1] = &w;
vals[2] = &c;
vals[3] = &z;
uint qcount = c;
std::string line;
std::getline(std::cin, line);
getNums(line, vals, 3);
Grid grid(w, h);
for (int i = 0; i < h && std::getline(std::cin, line); i++) {
if (line.size() == 0)
continue;
for (int x = 0; x < w; x++) {
grid.setc(x, i, line[x] == 46 ? UNIN : MONS);
}
// std::copy(line.data(), line.data() + w, grid.cgrid + i * w);
}
for (int i = 0; std::getline(std::cin, line); i++) { ///// I != 1 111111111
// if (i != 2)
// continue;
getNums(line, vals, 4);
std::cout <<
grid.solve(w - 1, h - 1, z - 1, c - 1) << "\n";
// std::cout << line << ": "<< h << " " << w << " " << c << " " << z<<"\n";
}
//grid.print();
}
Test details
Test 1 (public)
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 4 6 5 .*.*** *...** *****. *..*.* ... |
| correct output |
|---|
| 1 0 3 3 -1 |
| user output |
|---|
| 1 0 3 3 -1 |
Test 2
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 10 .......... .....*.... ........*. *.*....*.. ... |
| correct output |
|---|
| 1 2 1 2 2 ... |
| user output |
|---|
| 1 2 1 2 2 ... |
Test 3
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 10 *...***.** *****.*... **..**.**. ..**.**.*. ... |
| correct output |
|---|
| 1 2 2 1 2 ... |
| user output |
|---|
| 1 2 2 1 2 ... |
Test 4
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 10 ***.*.**** ********** *.******** .*.***.**. ... |
| correct output |
|---|
| 3 4 2 3 4 ... |
| user output |
|---|
| 3 4 2 3 4 ... |
Test 5
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 10 1 .****.**** **.**..*** ********** *******..* ... |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Test 6
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 .*...*.....*******..**...*....... |
| correct output |
|---|
| 2 3 3 2 2 ... |
| user output |
|---|
| 2 3 3 2 2 ... |
Test 7
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 ...*......**.**.*.*..**..*..**... |
| correct output |
|---|
| 2 2 2 2 3 ... |
| user output |
|---|
| 2 2 2 2 3 ... |
Test 8
Group: 2, 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 250 **..**..****.****.*.***.***..*... |
| correct output |
|---|
| 2 3 3 3 3 ... |
| user output |
|---|
| 2 3 3 3 3 ... |
Test 9
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 ...*.**.*..*.............*.*..... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 10
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 **.**..*.*.*.******....****.*.... |
| correct output |
|---|
| 2 1 3 2 2 ... |
| user output |
|---|
| (empty) |
Test 11
Group: 3, 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 40 40 200000 .*.*.**.*****.***.*.****.**.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 12
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *....**.***..****...*.....*...... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 13
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 .***.*..*.***..*****....**...*... |
| correct output |
|---|
| 3 2 2 3 2 ... |
| user output |
|---|
| (empty) |
Test 14
Group: 4, 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 80 80 200000 *******.*****.*..*..****...***... |
| correct output |
|---|
| 2 3 1 2 2 ... |
| user output |
|---|
| (empty) |
Test 15
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *....*..*..*..**..*.........**... |
| correct output |
|---|
| 3 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 16
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..*....*..*......*.**.*.*..***... |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 17
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *..*.*****.*********.****.****... |
| correct output |
|---|
| 3 3 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 18
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 *********.**********.******.**... |
| correct output |
|---|
| 3 3 3 3 3 ... |
| user output |
|---|
| (empty) |
Test 19
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 104 422 145 93 65 ... |
| user output |
|---|
| (empty) |
Test 20
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ..****************************... |
| correct output |
|---|
| 57 155 38 65 98 ... |
| user output |
|---|
| (empty) |
Test 21
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 .*****************************... |
| correct output |
|---|
| 498 498 498 498 498 ... |
| user output |
|---|
| (empty) |
Test 22
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 10 1 10 * * . * ... |
| correct output |
|---|
| 0 1 1 0 0 ... |
| user output |
|---|
| 0 1 1 0 0 ... |
Test 23
Group: 1, 2, 3, 4, 5
Verdict: ACCEPTED
| input |
|---|
| 1 10 10 ........*. 1 7 1 10 1 4 1 7 1 5 1 1 ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 24
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 1 200000 * . * . ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 25
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 1 250 200000 *.*.*...*.*.**.***..**.*.*..**... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 1 1 1 1 1 ... |
Test 26
Group: 5
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 250 250 200000 ................................. |
| correct output |
|---|
| 2 2 2 2 2 ... |
| user output |
|---|
| (empty) |
Test 27
Group: 5
Verdict: ACCEPTED
| input |
|---|
| 250 250 200000 ******************************... |
| correct output |
|---|
| 0 0 0 0 0 ... |
| user output |
|---|
| 0 0 0 0 0 ... |
