# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498560 | The_Samurai | Red-blue table (IZhO19_stones) | C++98 | 2 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
/*
16
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
4 1
4 2
4 3
4 4
*/
void solve() {
int n, m, ans, x = 1;
cin >> n >> m;
if (n == 1) {
cout << m << '\n';
for (int i = 0; i < m; i++) {
cout << '-';
}
cout << '\n';
return;
}
// 4 1
if (n == 2) {
if (m == 1) {
cout << "2\n";
cout << "+\n+\n";
return;
}
cout << m << '\n';
for (int i = 0; i < m; i++) {
cout << '-';
}
cout << '\n';
for (int i = 0; i < m; i++) {
cout << '-';
}
cout << '\n';
return;
}
if (n == 3) {
if (m == 1) {
cout << "3\n";
cout << "+\n+\n+\n";
return;
}
cout << m + 1 << '\n';
for (int i = 0; i < 2; i++) {
for (int j = 0; j < m; j++) {
cout << '-';
}
cout << '\n';
}
for (int i = 0; i < m; i++) {
cout << '+';
}
cout << '\n';
return;
}
if (m <= 2) {
cout << n << '\n';
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << '+';
}
cout << '\n';
}
return;
}
if (m == 3) {
cout << n + 1 << '\n';
for (int i = 0; i < n; i++) {
cout << "++-\n";
}
return;
}
if (n == 4 && m == 4) {
cout << "5\n";
cout << "++++\n----\n----\n----\n";
return;
}
if (n == 4) {
cout << m + 1 << '\n';
for (int i = 0; i < 3; i++) {
for (int j = 0; j < m; j++) {
cout << '-';
}
cout << '\n';
}
for (int i = 0; i < m; i++) {
cout << '+';
}
cout << '\n';
return;
}
if (m == 4) {
cout << n + 1 << '\n';
for (int i = 0; i < n; i++) {
cout << "+++-\n";
}
return;
}
if (n == 5) {
cout << m + 2 << '\n';
for (int i = 0; i < 3; i++) {
for (int j = 0; j < m; j++) {
cout << '-';
}
cout << '\n';
}
return;
}
if (m == 5) {
cout << n + 2 << '\n';
for (int i = 0; i < n; i++) {
cout << "+++--\n";
}
return;
}
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |