# | Problem | Pass Rate (passed user / total user) |
---|---|---|
11935 | double-end-queue |
|
12257 | Only children make choice! |
|
12767 | The One Function and The Power Of Matrix |
|
13519 | Big Integer 2 |
|
13891 | Polymorphic naming convention conversion |
|
13895 | Football Game |
|
Description
There's a dequeue already define in "function.h" and stack , queue inherit from the _dequeue.
Please implement those function below:
stack::
void push(const _node N);
void pop();
_node* get_data();
queue::
void push(const _node N);
void pop();
_node* get_data();
Good luck.
Stack
A stack is an abstract data type that serves as a collection of elements, where a node can be added to a stack and removed from a stack only at its top. Two principal operations can be used to manipulate a stack: push, which adds an element at the top, and pop, which removes the element at the top of the collection.
Queue
A queue is an abstract data type that serves as a collection of elements, where nodes are removed only from the head of the queue and are inserted only at the tail of the queue. Two principal operations can be used to manipulate a queue: enqueue, which inserts an element at the tail, and dequeue, which removes the element at the head of the collection.
Input
There will be few instruction in input [cont] [inst] [data].
cont and inst will be string
cont will be "stack" or "queue"
inst will be "push", "pop", "front" for queue only and "top" for stack only.
data will be optional (only when push inst , it will give the data ")
"exit" means exit
Output
In every "get_data"(top or front) commands , it will be single line with the data.
Sample Input Download
Sample Output Download
Partial Judge Code
11935.cppPartial Judge Header
11935.hTags
Discuss
Description
"Cat or Dog? that's a good question. " Shakespeare never said, 2019.
In this questions there are three types of animals class have to be implemented. (Cat , Dog and Caog)
Coag is a kind of special animal mixed in Cat and Dog.
Dog can only throwball
Cat can only play with carton.
Caog do those things both.
when Dog / Caog playing throwball output "it looks happy!\n"
when Cat / Caog playing with carton output "it looks so happy!\n"
and also there's a zoo can count how many animals are in the zoo.
In this questions you have to implement 3 class (cat , dog and caog) based on the sample code.
Input
All input data would be finish in given main functions.
First number N would be N animals ( N < 10)
the following Ai numbers would types of animals.
And the T would be T instructions ( T < 30)
the following Ti would be index and instructions
Output
When Animals born Zoo will auto output which kind of animal is born and how many animals in the zoo.
When Animals dead Zoo will auto output which kind of animal isdeadand how many animals in the zoo.
when Dog / Caog playing throwball output "it looks happy!\n"
when Cat / Caog playing with carton output "it looks so happy!\n"
when Barking:
Cat would "meow!\n"
Dog would "woof!\n"
Caog would "woof!woof!meow!\n"
Sample Input Download
Sample Output Download
Partial Judge Code
12257.cppPartial Judge Header
12257.hTags
Discuss
Description
There is a function called "the one function",
the function is defined as:
F(N, M) = 1, if M <= N,
F(N, M) = F(N, M-1) + F(N, M - 2) + ... + F(N, M - N), if M > N
Given you N, M, tell the result of F(N, M) module 1000000009.
ouo.
Updated at: 2020/05/17 19:00, sorry for the typo in the description.
This is an exercise of operator overloading,
it is recommended that you can follow the partial judge code to finish your work.
There are 8 member functions and 1 additional function that you should implement.
Read the comments carefully to better understand the structure of the partial judge code.
You should choose 'c++11' as the option of submission.
For sample input 1,
N = 3, M = 5,
so F(3, 1) = F(3, 2) = F(3, 3) = 1,
and F(3, 4) = F(3, 3) + F(3, 2) + F(3, 1) = 3
and F(3, 5) = F(3, 4) + F(3, 3) + F(3, 2) = 5
and F(3, 5) % 100000009 = 5,
so the output must be 5.
Input
The input contains 1 line,
the first line contains 2 numbers N, M.
It is guaranteed that:
1 <= N <= 100
1 <= M <= 10^9
Output
The output contains 1 line.
Output the answer of F(N, M), and a newline character at the end of line.
Sample Input Download
Sample Output Download
Partial Judge Code
12767.cppPartial Judge Header
12767.hTags
Discuss
Description
This is a problem extended from Problem 13487 (nthu.edu.tw).
Instead of doing addition, you are asked to implement the operator * to perform multiplication.
The following is the class INT:
#include <iostream>
class INT {
public:
INT();
void mulby10();
INT operator=(INT);
INT operator+(INT);
INT operator*(INT);
friend std::istream &operator>>(std::istream &, INT &);
friend std::ostream &operator<<(std::ostream &, INT);
private:
char *data;
int len;
};
Except INT operator*(INT), other functions has been implemented and provided in main.cpp. You should check how the operators +, >>, << are implemented and how the data is stored.
Note that additional tool mulby10() is provided to multiply INT by 10. For instance:
cout << a << endl; // Print: 1234
a.mulby10();
cout << a << endl; // Print: 12340
You have two ways to implement the multiplication:
- Perform long multiplication (直式乘法). Be careful of overflow problem since char can only holds data from 0 to 255 (28-1).
- Break the multiplication into several additions:
456*123=456*(100+20+3)=456*(100+10+10+1+1+1)
Input
There are two lines. Each line has a single integer.
No leading 0's are given in the test cases. E.g. 0001239487.
The total length of the two integers is at most 10000 characters.
Output
Compute and output the product of the two integers.
Sample Input Download
Sample Output Download
Partial Judge Code
13519.cppPartial Judge Header
13519.hTags
Discuss
Description
In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation, with the goal of enhancing program readability.
For the naming of identifiers, a common recommendation is "Use meaningful identifiers." A single word may not be as meaningful, or specific, as multiple words. Consequently, some naming conventions specify rules for the treatment of "compound" identifiers containing more than one word. Three most popular naming conventions are explained below:
- kebab case is a naming convention where words are separated by hyphens (“-”). For example, my-variable-name or my-function-name are examples of the kebab case.
- snake case is a naming convention where words are separated by underscores (“_”). For example, my_variable_name or my_function_name are examples of the snake case.
- camel case is a naming convention where the first letter of each word is capitalized and there are no separators. For example, MyVariableName or MyFunctionName are examples of the camel case.
(From Wikipedia, the free encyclopedia, https://en.wikipedia.org/wiki/Naming_convention_(programming))
In this problem, we consider an Integrated Development Environment (IDE) that supports naming convention conversion. We assume that the kebab case is the default naming convention. The IDE can convert to a different naming convention according to a programmer's preference. The IDE can also revert back to the default naming convention for the integration among multiple program files.
We first design the abstract base class ‘Case’ as an interface, which contains two pure virtual member functions:
- convert: convert to the desired naming convention;
- revert: revert back to the default naming convention, i.e., the kebab case.
#include <iostream>
#include <string>
using namespace std;
class Case{
protected:
bool converted;
string name;
public:
virtual void convert() = 0;
virtual void revert() = 0;
virtual ~Case(){}
Case(string s): converted(false), name(s){}
void show(ostream &os){
os << name;
}
bool is_converted() const{
return converted;
}
};
class SnakeCase : public Case{
public:
SnakeCase(string s): Case(s){}
void convert(){
converted = true;
for(int i = 0; i < name.length(); i++){
if(name[i] == '-') name[i] = '_';
}
}
void revert(){
converted = false;
for(int i = 0; i < name.length(); i++){
if(name[i] == '_') name[i] = '-';
}
}
};
class CamelCase : public Case{
public:
CamelCase(string s): Case(s){}
void convert();
void revert();
};
In ‘function.h’, we also add the class ‘SnakeCase’ as a sample of implementing a derived class of the base class ‘Case’.
You are asked to implement another derived class ‘CamelCase’ by overriding the two virtual functions, convert and revert.
Note
It is highly recommended to practice std::stringstream in this problem. Here is a simple code that shows you how to use stringstream:
#include <iostream>
#include <sstream> // header file for stringstream
using namespace std;
int main(){
string s;
stringstream ss;
getline(cin, s);
ss << s;
while(!ss.eof()){
string t;
getline(ss, t, ' ');
cout << t << "\n";
}
return 0;
}
/*
- Sample Input
This is a sentence for testing this code.
- Sample Output
This
is
a
sentence
for
testing
this
code.
*/
For more information, please refer to this article.
Input
A line contains only lowercase letters and hyphens.
Output
The Snake case and the Camel case for the input string. Please refer to the sample output for details.
Sample Input Download
Sample Output Download
Partial Judge Code
13891.cppPartial Judge Header
13891.hDiscuss
Description
You are going to broadcast a football game.
The field of this game is length of \(n\), width of \(m\), and there are \(p\) players who's ready to joint this game.
During the game, there would be some events which you need to handle.
Type 1: A player numbered \(player_id\) has catched the ball.
Type 2: The player who's holding the ball has kicked it along the direction of (\(dx\), \(dy\)). The ball would stop moving if it has hit the boundary of this field (\(x = 0\), \(x = n-1\), \(y = 0\), \(y = m-1\)), or any player on its way, except the players who was standing at its initial position
Type 3: You have to report the current state of this game.
In this problem, event except type 2 has been implemented for you.
To fulfill the requirements, you should also implement the functions GetWho(), which returns the player id of the one that is holding the ball right now, or -1 if no player is holding the ball.
Next, you should implement the function SomeoneIsHere(), which returns if there's any player standing at a specific position