#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <climits>
#include <queue>
#include <fstream>
#include <iomanip>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
#define ll long long
#define ff first
#define ss second
#define MP make_pair
#define pb push_back
#define pf push_front
#define db double
ll gcd(ll a,ll b){
return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a,ll b){
return a / gcd(a, b) * b;
}
ll binary_power(ll a,ll n){
ll res = 1;
while(n){
if(n & 1) -- n, res = res * a;
else a = a * a, n >>= 1;
}
return res;
}
ll phi(ll n) {
ll result = n;
for (ll i = 2; i * i <= n; ++i)
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i;
}
if (n > 1)
result -= result / n;
return result;
}
/*<______________________________________________>*/
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
char chang(char a){
if(a == '+') return '-';
return '+';
}
void t_main(){
int n, m, res, cnt; cin >> n >> m;
char a = '+';
if(n < m) a = '-';
vector <vector<char>> g(n + 1, vector <char> (m + 1, a));
if(m == n){
res = m; cnt = (m + 1) / 2 - 1; res += cnt;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= cnt; j ++)
g[i][j] = chang(g[i][j]);
cout << res << "\n";
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++)
cout << g[i][j];
cout << "\n";
}
}
else if(n < m){
res = m; cnt = (n + 1) / 2 - 1; res += cnt;
for(int i = 1; i <= cnt; i ++)
for(int j = 1; j <= m; j ++)
g[i][j] = chang(g[i][j]);
cout << res << "\n";
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++)
cout << g[i][j];
cout << "\n";
}
}
else{
res = n; cnt = (m + 1) / 2 - 1; res += cnt;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= cnt; j ++)
g[i][j] = chang(g[i][j]);
cout << res << "\n";
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++)
cout << g[i][j];
cout << "\n";
}
}
}
signed main(){
//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt = 1;
cin >> tt;
while(tt --) t_main();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
3 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
1256 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
1204 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
3 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |