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>
#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 (stderr)
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);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |