#include<bits/stdc++.h>
#define fi first
#define se second
#define len(x) (int)(x).size()
#define pb push_back
#define p2(x) (x)*(x)
#define all(x) (x).begin() , (x).end()
#define mkp make_pair
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("-O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long double ld;
typedef long long ll;
void solve(int n , int m){
/// red okay???
/// lulz
pair < int , int > best = {-1 , -1};
int ans = 0;
for(int A = 0; A <= n; ++A){
/// lulz
int ost = m - (m + 2)/2;
int need = max(0 , (n+2)/2 - (n-A));
int B;
if(need == 0){
B = m;
if(ans < A + B)
ans = A + B , best = {A , B};
}else{
B = (A * ost) / need;
B = min(B , m);
if(ans < A + B)
ans = A + B , best = {A , B};
}
}
/// lulz
cout << ans << '\n';
vector<int>column(m);
int A = best.fi , B = best.se;
int ost = m - (m + 2)/2;
int need = max(0 , (n+2)/2 - (n-A));
if(need == 0){
for(int i = 0 ; i < n; ++i){
if(A){
for(int j = 0 ; j < (m+2)/2;++j)
cout << '+';
for(int j = (m+2)/2; j < m; ++j)
cout << '-';
A--;
}else{
for(int j = 0 ; j < m; ++j)
cout << '-';
}
cout << '\n';
}
}else{
// system("pause");
// cout << " YO " << n << ' '<< m << '\n';
// cout << "YO\n";
// cout << A << ' ' << B << '\n';
// cout << ost << ' ' << need << '\n';
for(int i = 0 ; i < n; ++i){
if(A){
/// poses
string cur = string(m , '+');
for(int j = (i/need)*ost ; j < (i/need)*ost + ost; ++j){
if(j >= 0 && j < m)
cur[j] = '-';
}
cout << cur;
A--;
}else{
for(int j = 0 ; j < m; ++j)
cout << '-';
}
cout << '\n';
}
}
}
int main(){
ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
int t;
cin >> t;
// for(int i = 1; i<=10; ++i)
// for(int j = 1; j <= 10; ++j)
// solve(i , j);
while(t--){
int n ,m ;
cin >> n >> m;
solve( n , m);
}
}
/*
*/
Compilation message
stones.cpp: In function 'void solve(int, int)':
stones.cpp:46:23: warning: unused variable 'B' [-Wunused-variable]
46 | int A = best.fi , B = best.se;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
380 KB |
Output is correct |
4 |
Incorrect |
2 ms |
492 KB |
in the table A+B is not equal to 41 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
1388 KB |
in the table A+B is not equal to 78 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1388 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
380 KB |
Output is correct |
4 |
Incorrect |
2 ms |
492 KB |
in the table A+B is not equal to 41 |