#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "INTERNET"
#define pll pair<ll, ll>
#define pi pair<ll, pll>
#define fi first
#define se second
using namespace std;
const ll mod = 1e17;
const ll N = 3e3+5;
const int base = 350;
const int base2 = 311;
ll n, m, t, k, T, tong, a[N][N], b[N], c[N], d[N], ans, dp[N], lab[N], h[N], P[N][20];
vector<ll> adj[N], kq;
pll p[N];
ll pw(ll k, ll n)
{
ll total = 1;
for(; n; n >>= 1)
{
if(n & 1)total = total * k % mod;
k = k * k % mod;
}
return total;
}
string s;
bool cmp(pll x, pll y)
{
return (long double) 1.0 * x.se / x.fi > (long double) 1.0 * y.se / y.fi;
}
void sol()
{
cin >> n >> m;
bool ok = false;
if(n < m)
{
swap(n, m);
ok = true;
}
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)a[i][j] = 1;
}
k = 0;
tong = 0;
for(int j = 1; j <= (m-1)/2; j ++)
{
for(int i = 1; i <= n; i ++)
{
++k;
a[i][tong+1] = 0;
if(k == n/2+1)
{
k = 0;
++tong;
}
}
}
cout << n + tong << '\n';
if(ok)swap(n, m);
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)
{
if(ok)
{
if(a[j][i])cout << '-';
else cout << '+';
}
else
{
if(a[i][j])cout << '+';
else cout << '-';
}
}
cout << '\n';
}
}
int main()
{
if(fopen(task".in", "r"))
{
freopen(task".in", "r", stdin);
freopen(task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ntest = 1;
cin >> ntest;
while(ntest -- > 0)
sol();
}
/*
5
100
12
8
2021
10000
*/
Compilation message
stones.cpp: In function 'int main()':
stones.cpp:85:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
85 | freopen(task".in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:86:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
86 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
1872 KB |
Output is correct |
2 |
Correct |
53 ms |
10012 KB |
Output is correct |
3 |
Correct |
38 ms |
10676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
1988 KB |
Output is correct |
2 |
Correct |
32 ms |
8144 KB |
Output is correct |
3 |
Correct |
29 ms |
6004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
3 ms |
588 KB |
Output is correct |
5 |
Correct |
44 ms |
1872 KB |
Output is correct |
6 |
Correct |
53 ms |
10012 KB |
Output is correct |
7 |
Correct |
38 ms |
10676 KB |
Output is correct |
8 |
Correct |
35 ms |
1988 KB |
Output is correct |
9 |
Correct |
32 ms |
8144 KB |
Output is correct |
10 |
Correct |
29 ms |
6004 KB |
Output is correct |
11 |
Correct |
9 ms |
768 KB |
Output is correct |
12 |
Correct |
30 ms |
7648 KB |
Output is correct |
13 |
Correct |
32 ms |
7700 KB |
Output is correct |
14 |
Correct |
24 ms |
5936 KB |
Output is correct |
15 |
Correct |
39 ms |
13224 KB |
Output is correct |
16 |
Correct |
37 ms |
10524 KB |
Output is correct |
17 |
Correct |
15 ms |
5980 KB |
Output is correct |