| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11431 | String Operation |
|
| 11920 | Matrix Chain Multiplication |
|
| 11933 | Vector Dot |
|
Description
Given a set of strings, perform the operations according to the following commands.
Commands: (n will not be equal to m)
s n m:
Swap the nth string and the mth string.
i n m:
Insert the mth string at the tail of the nth string.
si n m:
Swap the specified strings first, and then insert.
is n m:
Insert first, and then swap the two specified strings.
t n m:
If the nth string is equal to the mth string, do i n m. Otherwise, do s n m.
e:
Exit.
Note:
You will be provided with main.cpp and function.h, and asked to implement function.cpp including
Str::Str(char*);
Str::Str(const Str &);
bool Str::operator==( const Str &) const;
Input
The first line is an integer N indicating the number of input strings.
The following N lines each contains one input string.
Starting from the N+2th line will be a sequence of commands.
Output
Output the final result of the input strings.
Sample Input Download
Sample Output Download
Partial Judge Code
11431.cppPartial Judge Header
11431.hTags
Discuss
Description
**[2018/5/12 02:12 PM] : Sorry for the confusion (get_row, get_col) in the original code! The partial code provided has been improved for clarity and all submissions to this problem has been rejudged! For new submissions, please check out the new partial code! Sincerely apologize for the inconvenience caused!**
There are few Matrix stored in MatrixChain Class , please implement the calc function to get chain multiplication of them.
Your task is to implement the following three functions:
Matrix Matrix::operator*(const Matrix &a) const
Matrix Matrix::operator=(const Matrix &a)
Matrix MatrixChain::calc(int l, int r) const
Definition of Chain Multiplication: Given l, r and an array arr of matrices, calculate the result matrix of arr[l] * arr[l+1] * ... * arr[r-1]
Hint : Σ(A[r][k] * B[k][c]) = C[r][c], where C is a matrix with r rows and c columns.
Input
Input will be done by main.cpp so don't worried about it
int T means T matrices
for T : 0 < T < 11
then T matrices with row , col , and each of elements value
for row , col: 0 < row , col < 11
for value of Matrix elements: 0 < value < 11
Finally, give l, r to get the calc() function's answer.
Output
output will also be done by main.cpp so don't worried about it
it will output the calc function's answer .
Sample Input Download
Sample Output Download
Partial Judge Code
11920.cppPartial Judge Header
11920.hTags
Discuss
Description
Implement a Vector class that support n-dimensional vector dot product.
Your task is to complete
- const int operator[](int index) const;
- int operator*(const Vector& a);
inside the Vector class;
Remember to #include "function.h"!
Input
First line of input is an integer m, where m is the number of testcases.There are m testcases following.
A testcases consists of three lines:
- In the first line of each testcase, there are a string OP and an integer n, where OP is the operation and n is the vector size.
- In the second line of each testcase, there are n integers, representing all the elements inside the first vector, A.
- In the third line of each testcase, there are n integers, representing all the elements inside the second vector, B.
It is guaranteed that:
- 1 ≤ n, m ≤ 100
- For all the elements x in vector A and B, |x| ≤ 100
Output
For each testcase, according to its operation, output the result of A*B. There is a space after every number.