이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
#include <string>
#include <ios>
#include <iomanip>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL);
#define CY cout<<"YES"<<endl
#define CN cout<<"NO"<<endl
#define ll long long
#define ciN cin
#define itn int
#define pshb push_back
#define sz size()
#define vec vector<int>
#define vecl vector<long long>
#define fro for
#define Int int
#define stirng string
#define nedl endl
#define pi 3.141592653589793238463
#define endl '\n'
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
void solve() {
int n, m; cin >> n >> m;
if (n == m && n>5) {
if (n &1) {
cout << n * 2 - 2 << endl;
for (itn i = 0; i < n/2; i++) {
for (itn j = 0; j < n-1; j++) {
if (j & 1)cout << '+';
else cout << '-';
if (j == n - 2)cout << '+';
}
cout << endl;
}
fro(int i = 0; i < n; i++) {
cout << '-';
}
cout << endl;
for (itn i = 0; i < n/2; i++) {
for (itn j = 0; j < m; j++) {
if (j & 1)cout << '-';
else cout << '+';
}
cout << endl;
}
}
else {
cout << (n - 2) * 2 << endl;
for (int i = 0; i < (n - 2) / 2; i++) {
for (itn j = 0; j < n - 2; j++) {
if (j & 1)cout << '+';
else cout << '-';
if (j == n - 3)cout << "++";
}
cout << endl;
}
for (itn i = 0; i < 2; i++) {
for (itn j = 0; j < n; j++) {
cout << '-';
}
cout << endl;
}
for (int i = 0; i < (n - 2) / 2; i++) {
for (itn j = 0; j < n - 2; j++) {
if (j & 1)cout << '-';
else cout << '+';
if (j == n - 3)cout << "++";
}
cout << endl;
}
}
return;
}
if (m > n) {
ll sum = m + (n - (n / 2 + 1));
cout << sum << endl;
for (int i = 0; i < (n / 2) + 1; i++) {
for (int j = 0; j < m; j++) {
cout << '-';
}
cout << endl;
}
for (int i = 0; i < n-(n/2+1); i++) {
for (int j = 0; j < m; j++) {
cout << '+';
}
cout << endl;
}
}
else {
ll sum = n + (m - (m / 2 + 1));
cout << sum << endl;
string str;
for (int i = 0; i < (m / 2) + 1; i++) {
str.pshb('+');
}
for (int i = 0; i < m - (m / 2 + 1); i++) {
str.pshb('-');
}
for (itn i = 0; i < n; i++) {
cout << str << endl;
}
}
}
signed main() {
FASTIO
int t; cin >> t;
while (t--)
solve();
}
# | 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... |