이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n, m;
cin >> n >> m;
if(n >= 3 && m >= 3){
if(n < m){
int s = m;
char a[100][100];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
a[i][j] = '-';
}
}
if(n % 2 && m % 2){
s += n / 2;
for(int i = 0; i < n / 2; i++){
for(int j = 0; j < m / 2 + 1; j++){
a[i][j] = '+';
}
}
}else if(n % 2 && m % 2 == 0){
s += n / 2;
for(int i = 0; i < n / 2; i++){
for(int j = 0; j < m / 2 + 1; j++){
a[i][j] = '+';
}
}
}else if(n % 2 == 0 && m % 2){
s += n / 2;
for(int i = 0; i < n / 2; i++){
for(int j = 0; j < m / 2 + 1; j++){
a[i][j] = '+';
}
}
} else{
s += n / 2;
for(int i = 0; i < n / 2; i++){
for(int j = 0; j < m / 2 + 1; j++){
a[i][j] = '+';
}
}
}
cout << s << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j];
}
cout << '\n';
}
}
else{
int s = n;
char a[100][100];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
a[i][j] = '+';
}
}
if(n % 2 && m % 2){
s += m / 2;
for(int i = 0; i < n / 2 + 1; i++){
for(int j = 0; j <= m / 2 - 1; j++){
a[i][j] = '-';
}
}
}else if(n % 2 && m % 2 == 0){
s += m / 2 - 1;
for(int i = 0; i < n / 2 + 1; i++){
for(int j = 0; j < m / 2 - 1; j++){
a[i][j] = '-';
}
}
}else if(n % 2 == 0 && m % 2){
s += m / 2;
for(int i = 0; i < n / 2 + 1; i++){
for(int j = 0; j < m / 2; j++){
a[i][j] = '-';
}
}
} else{
s += n / 2 - 1;
for(int i = 0; i < n / 2 + 1; i++){
for(int j = 0; j < m / 2 - 1; j++){
a[i][j] = '-';
}
}
}
cout << s << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j];
}
cout << '\n';
}
}
} else{
if(n < m){
cout << m << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << '-';
}
cout << '\n';
}
} else{
cout << n << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << '+';
}
cout << '\n';
}
}
}
}
int main(){
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... |