#include<bits/stdc++.h>
#define f first
//#define int long long
#define s second
#define pii pair<int,int>
using namespace std;
const int N=1e3+5,mod=1e9+7;
int t,n,m,red[N];
char a[N][N];
set<pii> s;
main(){
// t=1;
cin >> t;
while(t--){
cin>>n>>m;
for(int i=1;i<=m;i++) red[i] = 0;
int ans = m,B_=m,A_ = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++) a[i][j]='-';
}
for(int i=1;i<=n;i++){
s.clear();
int all=i*(m/2+1);
int l = 0, r=m,B=0;
while(l<=r){
int mid=(l+r)/2;
for(int i=1;i<=mid;i++) {
all -= min(all,i);
}
if((n-1)/2*(m-mid) >= all) r=mid-1,B=mid;
else l=mid+1;
}
if(i+m-B > ans) ans=i+m-B,A_=i,B_=m-B;
}
int all = A_*(m/2+1);
cout<<ans<<endl;
for(int i=1;i<=A_;i++) {
for(int j=1;j<=m-B_;j++) {
a[i][j]='+';
}
int c = m/2+1 - (m-B_);
for(int j=m-B_+1;j<=m;j++){
if(!c) break;
if(red[j]+1<=(n+1)/2) red[j]++,c--,a[i][j]='+';
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
cout<<a[i][j];
cout<<endl;
}
}
}
Compilation message
stones.cpp:11:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main(){
| ^~~~
stones.cpp: In function 'int main()':
stones.cpp:38:7: warning: unused variable 'all' [-Wunused-variable]
38 | int all = A_*(m/2+1);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
in the table A+B is not equal to 3 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
332 KB |
in the table A+B is not equal to 48 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
in the table A+B is not equal to 3 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
94 ms |
1376 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
1344 KB |
in the table A+B is not equal to 40 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
in the table A+B is not equal to 3 |