#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ssort sort(s.begin(),s.end());
#define sreverse reverse(s.begin(),s.end());
#define sclear s.clear();
#define ssize s.size();
#define ld long double
#define F first
#define S second
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define sq(a) (a)*(a)
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
ll a,b,c,e,d,f,k,g,h,r,i,j,x,y,z,m,n,l,t,p,s,u,sum,ans,mod=1e18;
char arr[200][200];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>a;
for(i=1;i<=a;i++)
{
cin>>n>>m;
if(n==1&&m==1){
cout<<1<<endl<<'+'<<endl; continue;
}
if(n>m){
swap(n,m); r=1; //swapped
}
for(j=1;j<=n;j++){
for(k=1;k<=m;k++){
if(r==1) arr[j][k]='+';
else arr[j][k]='-';
}
}
l=min(n,(n/2-!(n%2))*m/(m/2+1));
cout<<m+l<<endl;
for(j=1;j<= l ;j++){
for(k=1;k<=m/2+1;k++)
{
h++;
if(h>m) h=1;
if(r==1){
arr[j][h]='-';
}
else{
arr[j][h]='+';
}
}
}
if(r==1){
for(j=1;j<=m;j++)
{
for(k=1;k<=n;k++)
{
cout<<arr[j][k];
}
cout<<endl;
}
}
else{
for(j=1;j<=n;j++)
{
for(k=1;k<=m;k++)
{
cout<<arr[j][k];
}
cout<<endl;
}
}
}
}
Compilation message
stones.cpp: In function 'void fopn(std::string)':
stones.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
17 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
324 KB |
invalid character |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
340 KB |
in the table A+B is not equal to 2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
324 KB |
invalid character |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
1300 KB |
invalid character |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
1336 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
324 KB |
invalid character |
3 |
Halted |
0 ms |
0 KB |
- |