#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;
char a[N][N];
set<pii> s;
main(){
// t=1;
cin >> t;
while(t--){
cin>>n>>m;
s.clear();
for(int i=1;i<=m;i++) s.insert({0,i});
int B = m;
int ans = B,cnt=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++){
for(int j=1;j<=m/2+1;j++) {
pii c = *s.begin();
s.erase(c);
s.insert({c.f+1,c.s});
if(c.f+1==n/2+1) B--;
}
if(i+B>ans) ans=i+B,cnt=i;
}
cout<<ans<<endl;
s.clear();
for(int i=1;i<=m;i++) s.insert({0,i});
for(int i=1;i<=cnt;i++){
for(int j=1;j<=m/2+1;j++) {
pii c = *s.begin();
s.erase(c);
s.insert({c.f+1,c.s}); a[i][c.s] = '+';
if(c.f+1==n/2+1) B--;
}
}
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(){
| ^~~~
# |
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 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
304 KB |
in the table A+B is not equal to 2 |
# |
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 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
212 ms |
1368 KB |
Wrong answer in test 97 21: 112 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
193 ms |
1428 KB |
in the table A+B is not equal to 46 |
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 2 |