Task: | Ratsun reitit |
Sender: | Salama |
Submission time: | 2020-09-30 21:31:30 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#8 | ACCEPTED | 0.01 s | 2, 3 | details |
#9 | ACCEPTED | 0.01 s | 2, 3 | details |
#10 | ACCEPTED | 0.01 s | 2, 3 | details |
#11 | ACCEPTED | 0.01 s | 3 | details |
#12 | ACCEPTED | 0.01 s | 3 | details |
#13 | ACCEPTED | 0.01 s | 3 | details |
Code
#include <iostream> #include <string> #include <algorithm> using namespace std; void printBoard(int board[], int size) { board[0] = 0; for(int y = 0; y < size;) { for(int x = 0; x < size;) { cout << board[x + size * y]; if(++x != size) cout << " "; } if(++y != size) cout << "\n"; } return; } int* initArray(int size) { int* board = new int[size*size]; for(int i = 1; i < (size*size); i++) board[i] = 0; board[0] = -1; return board; } int main() { int size; cin >> size; // Pyydetään koko int* board = initArray(size); //Luodaan lauta int moveCount = 1; //Alkuperäinen aktiivisien siirtojen määrä int newMoveCount = -1; int* newMoves = new int[size*size]; int* latestMoves = new int[moveCount]; //Viimeisimpien siirtojen sijainnit (index) latestMoves[0] = 0; //Alkuperäinen ensimmäisen siirron sijainti int moveIndex = 0; while(newMoveCount != 0) { newMoves = new int[size*size]; newMoveCount = 0; moveIndex++; for(int i = 0; i < moveCount; i++) { //Jokainen aktiivinen siirto läpi // --> if(latestMoves[i] % size < size - 2) { //Ei mene oikeasta laidasta yli // X //OXX if(latestMoves[i] > size) { //Ei mene ylälaidasta yli if(board[latestMoves[i] + 2 - size*1] == 0) { board[latestMoves[i] + 2 - size*1] = moveIndex; newMoves[newMoveCount] = latestMoves[i] + 2 - size*1; newMoveCount++; } } //OXX // X if(latestMoves[i] < size*size-size) { //Ei mene alalaidasta ali if(board[latestMoves[i] + 2 + size*1] == 0) { board[latestMoves[i] + 2 + size*1] = moveIndex; newMoves[newMoveCount] = latestMoves[i] + 2 + size*1; newMoveCount++; } } } // <-- if(latestMoves[i] % size >= 2) { //Ei mene vasemmasta laidasta yli //X //XXO if(latestMoves[i] > size) { //Ei mene ylälaidasta yli if(board[latestMoves[i] - 2 - size*1] == 0) { board[latestMoves[i] - 2 - size*1] = moveIndex; newMoves[newMoveCount] = latestMoves[i] - 2 - size*1; newMoveCount++; } } //XXO //X if(latestMoves[i] < size*size-size) { //Ei mene alalaidasta ali if(board[latestMoves[i] - 2 + size*1] == 0) { board[latestMoves[i] - 2 + size*1] = moveIndex; newMoves[newMoveCount] = latestMoves[i] - 2 - size*1; newMoveCount++; } } } // ^ // | if(latestMoves[i] > size) { //Ei mene ylälaidasta yli //XX // X // O if(latestMoves[i] % size >= 1) { //Ei mene vasemmasta laidasta yli if(board[latestMoves[i] - 1 - size*2] == 0) { board[latestMoves[i] - 1 - size*2] = moveIndex; newMoves[newMoveCount] = latestMoves[i] - 1 - size*2; newMoveCount++; } } //XX //X //O if(latestMoves[i] % size < size - 1) { //Ei mene oikeasta laidasta yli if(board[latestMoves[i] + 1 - size*2] == 0) { board[latestMoves[i] + 1 - size*2] = moveIndex; newMoves[newMoveCount] = latestMoves[i] + 1 - size*2; newMoveCount++; } } } // | // V if(latestMoves[i] < size*size-size) { // if(latestMoves[i] % size >= 1) { //Ei mene vasemmasta laidasta yli if(board[latestMoves[i] - 1 + size*2] == 0) { board[latestMoves[i] - 1 + size*2] = moveIndex; newMoves[newMoveCount] = latestMoves[i] - 1 + size*2; newMoveCount++; } } //XX //X //O if(latestMoves[i] % size < size - 1) { //Ei mene oikeasta laidasta yli if(board[latestMoves[i] + 1 + size*2] == 0) { board[latestMoves[i] + 1 + size*2] = moveIndex; newMoves[newMoveCount] = latestMoves[i] + 1 + size*2; newMoveCount++; } } } } latestMoves = new int[newMoveCount]; std::copy_n(newMoves, newMoveCount, latestMoves); moveCount = newMoveCount; } printBoard(board, size); //Lopuksi tulosta valmis lauta }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
0 3 2 5 3 4 1 2 2 1 4 3 5 2 3 2 |
user output |
---|
0 3 2 3 3 3 1 2 2 1 4 3 4 2 3 2 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
0 3 2 3 2 3 4 1 2 3 2 1 4 3 2 3 2 3 2 3 2 3 2 3 4 |
user output |
---|
0 3 2 3 2 3 4 1 2 3 2 1 4 3 2 3 2 3 2 3 2 3 2 3 4 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
6 |
correct output |
---|
0 3 2 3 2 3 3 4 1 2 3 4 2 1 4 3 2 3 3 2 3 2 3 4 2 3 2 3 4 3 ... |
user output |
---|
0 3 2 3 2 3 3 4 1 2 3 4 2 1 4 3 2 3 3 2 3 2 3 4 2 3 2 3 4 3 ... |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
0 3 2 3 2 3 4 3 4 1 2 3 4 3 2 1 4 3 2 3 4 3 2 3 2 3 4 3 2 3 2 3 4 3 4 ... |
user output |
---|
0 3 2 3 2 3 4 3 4 1 2 3 4 3 2 1 4 3 2 3 4 3 2 3 2 3 4 3 2 3 2 3 4 3 4 ... Truncated |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
0 3 2 3 2 3 4 5 3 4 1 2 3 4 3 4 2 1 4 3 2 3 4 5 3 2 3 2 3 4 3 4 2 3 2 3 4 3 4 5 ... |
user output |
---|
0 3 2 3 2 3 4 5 3 4 1 2 3 4 3 4 2 1 4 3 2 3 4 5 3 2 3 2 3 4 3 4 2 3 2 3 4 3 4 5 ... Truncated |
Test 6
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
0 3 2 3 2 3 4 5 4 3 4 1 2 3 4 3 4 5 2 1 4 3 2 3 4 5 4 3 2 3 2 3 4 3 4 5 2 3 2 3 4 3 4 5 4 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 3 4 1 2 3 4 3 4 5 2 1 4 3 2 3 4 5 4 3 2 3 2 3 4 3 4 5 2 3 2 3 4 3 4 5 4 ... Truncated |
Test 7
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
10 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 3 4 1 2 3 4 3 4 5 6 2 1 4 3 2 3 4 5 4 5 3 2 3 2 3 4 3 4 5 6 2 3 2 3 4 3 4 5 4 5 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 3 4 1 2 3 4 3 4 5 6 2 1 4 3 2 3 4 5 4 5 3 2 3 2 3 4 3 4 5 6 2 3 2 3 4 ... Truncated |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
25 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
49 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 10
Group: 2, 3
Verdict: ACCEPTED
input |
---|
50 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
75 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
99 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
100 |
correct output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... |
user output |
---|
0 3 2 3 2 3 4 5 4 5 6 7 6 7 8 ... Truncated |