| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 13522 | Infinitely Big Integer: Darray Implementation |
|
| 13523 | Infinitely Big Integer: Big Integer Implementation |
|
| 14273 | Gomoku Battle |
|
| 14951 | Cat Maze |
|
Description
The problem "Infinitely Big Integer" is splitted into two subproblems:
- Darray Implementation (3/10)
- Big Integer Implementation (7/10)
You should solve this subproblem first.
Based on the definition of Dynamic Array in Problem 13520 (nthu.edu.tw), you need to implement a dynamic array with the following functions:
- int& operator[](int): access data like using array. Users and main.cpp should/will not access the index which is greater or equal to size.
- void pushback(int x): append the element x
- void popback(void): pop the last element. Don't do anything if the array is empty.
- void clear(void): clear the array (set size to 0) so that the next pushbacks will place elements in data[0],data[1] and so on.
- int length(void): return the current size.
- void resize(void): double the capacity and copy the data.
- ~Darray(): destructor
Note that main.cpp acts like a functional tester for your Darray. There's no need to understand it. You should test your Darray by yourself. Furthermore, a new function void popback(void) is introduced in this problem.
class Darray {
public:
Darray() {
capacity = 100;
size = 0;
data = new int[capacity];
};
~Darray();
int& operator[](int);
void pushback(int x);
void popback(void);
void clear(void);
int length(void);
private:
void resize(void); // double the capacity
int *data;
int capacity;
int size;
};
Darray arr;
for (int i = 0; i < 5; i++) arr.pushback(i*i);
arr[2] += 100 + arr[3];
for (int i = 0; i < arr.length(); i++)
cout << arr[2] << ' '; // Print: 0 1 113 9 16
cout << endl << arr.length() << endl; // Print: 5
arr.clear();
cout << arr.length() << endl; // Print: 0
arr.pushback(9487); arr.pushback(9487);
arr.popback();
cout << arr.length() << ' ' << arr[0] << endl; // Print: 1 9487
std::vector is prohibited (both subproblems 1 and 2) and will result in 0 score if you use it.
Input
This is handled by the main function.
1/3 of the test cases will not test popback(). If you have problems with it, try writing an empty popback function so that it can be compiled successfully.
void popback() {
}
Output
This is handled by the main function.
Sample Input Download
Sample Output Download
Partial Judge Code
13522.cppPartial Judge Header
13522.hTags
Discuss
Description
The problem "Infinitely Big Integer" is splitted into two subproblems:
- Darray Implementation (3/10)
- Big Integer Implementation (7/10)
You should solve the former, Darray Implementation, first.
You may have practiced the problem Big Integer before. Instead of using traditional int, we store the integer in a char array. However, it still has size limitation because we declare a static array for the class. In this problem, we'll use the Darray in problem 13522 - Infinitely Big Integer: Darray Implementation as the data array in class INT to handle arbitary large numbers as long as the memory of the computer is enough.
The following is the structure of INT.
public:
void operator+=(INT&);
friend std::istream &operator>>(std::istream &, INT &);
friend std::ostream &operator<<(std::ostream &, INT &);
private:
Darray data;
};
For simplicity, you only need to implement three functions, <<, >> and +=. The streaming operators are used for cin and cout. The operator += does the same as the traditional operator +=. For instance, A += B, A will be the value of A+B and B remains the same. Note that all the parameters are passed by reference, which is different from the previous problem.
Your function.cpp should contain the implementation of both Darray and INT. If you passed the subproblem 1 first, just copy and paste the Darray. For example:
#include "function.h"
// Darray
void Darray::pushback(int x) { ... }
...
// INT
void INT::operator+= (INT &b) { ... }
...
It is okay if you have problems with the popback function in subproblem 1 as long as the Darray has basic functionality to pass the test cases, because Darray in INT is fully controlled by you.
The following is an alternative main.cpp to test your code:
#include "function.h"
using namespace std;
int main() {
INT a, b;
cin >> a;
cin >> b;
a += b;
cout << "a + b = " << a << endl;
return 0;
}
Input
Output
Sample Input Download
Sample Output Download
Partial Judge Code
13523.cppPartial Judge Header
13523.hTags
Discuss
Description

This afternoon, Doraemon and DebugCatCapoo have a Gomoku battle.
However, they've slightly altered the rules since Capoo often ends up secretly eating the pieces Doraemon puts down...
In their version of Gomoku, Doraemon goes first. On his turn, he can put his pieces on two empty spots. When it's Capoo's turn, he puts his piece on one empty spot, and then picks a spot with a piece on it to remove (eat) that piece.
To simplify the rules, their game's goal is to form an unbroken line of 5+ pieces of their own color either horizontally or vertically, and the lines going diagonally don't count. If someone tries to play out of turn, that move is ignored. It's guaranteed that both players will not place pieces on occupied spaces or outside the board, and Capoo will not attempt to remove (eat) a piece from an empty space or outside the board.
This is a partial judge problem. Write a program to determine the winner of their Gomoku game. Please review the provided code and implement the section marked TODO in function.h.
Input
This problem consists of several test cases.
Each test case begins with a line containing an integer 5 ≤ N ≤ 10, which indicates the game is played on an N×N board. The lines that follow are formatted as <Doraemon/DebugCatCapoo> <location> <location>, where each location is a two-digit string, indicating the action taken by the player. There are no more than 100 actions taken by the two players for each round of the game.
For example, the actions taken by the players are represented as follows:
Doraemon 35 03means Doraemon places pieces on row 3, column 5, and row 0, column 3.DebugCatCapoo 32 04means DebugCatCapoo places a piece on row 3, column 2, and removes a piece from row 0, column 4.
Please note that sometimes a player may take action even when it's not their turn. For example, in the second action of round #1 in the sample input, it's DebugCatCapoo's turn, but Doraemon takes an action. In such cases, the move made by Doraemon will be ignored until DebugCatCapoo performs its move. You need to verify the value of GomokuGame::turn within the GomokuGame::place() and GomokuGame::remove(). If it's not the correct player's turn, return false to abort the action.
A string of - - - marks the end of a test case and the conclusion of the game.
Output
The winner of the game and the status of the board will be outputted.
(O -> Doraemon, X -> DebugCatCapoo, this part is already implemented)
Sample Input Download
Sample Output Download
Partial Judge Code
14273.cppPartial Judge Header
14273.hTags
Discuss
Description
A cat is trapped in a 20×20 maze. Each cell is one of the following types:
'S': starting position'E': exit position'#': wall'_': empty cell'+': food
The cat starts at 'S'. Initially, the whole maze is unknown to the cat.
The game proceeds in steps. In each step, the cat does the following:
- see and memorize cells adjacent to its current position, and then
- move to an adjacent cell based on its memory.
Two cells are adjacent if they share a side, that is, if one is directly above, below, to the left of, or to the right of the other.
When the cat moves onto a cell with food, the food is eaten and the cell becomes empty immediately.
Your goal is to make the cat eat all food and then reach the exit cell within 10000 steps.
Note
- Moving onto the exit cell before eating all food is allowed and does not cause the game to fail.
- All non-wall cells in the maze are guaranteed to be connected.
- The cat cannot move onto a wall cell.
Input
(The input is already handled by the provided C++ code.)
The input contains exactly 20 lines.
Each line contains exactly 20 characters, representing the maze.
The maze contains exactly one S and exactly one E.
The outer boundary of the maze is guaranteed to be #. (See the sample input for an example.)
Subtasks:
- Testcase 1 is the sample input.
- Testcase 2 contains no wall cells other than the outer boundary, and contain no food cells.
- Testcases 3 and 4 contain no food cells.
- Testcases 5, 6, and 7 have the starting position and the exit cell in adjacent cells.
- Testcases 8, 9, and 10 are general cases without additional restrictions.
Output
(The output is already handled by the provided C++ code.)
Output one line.
If the cat eats all food and reaches the exit within 10000 steps, output: SUCCESS.
Otherwise, output: FAIL.
You will receive an AC only if the program outputs SUCCESS.