// Muallif: Mansuraliyev Husanboy Murotali o'g'li >> NamPS
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const double PI=3.1415926535897932384626433832795;
// 0-9 >> 48-57; A-Z>>65-90 and a-z>>97-122 respectively;
int main()
{
ios;int t; cin>>t;while(t--){
map<int,int>row,col;
int n,m;
cin>>n>>m;
if(n==2&&m==1){
cout<<"2\n+\n+\n";continue;}
int mr=m/2+1,mc=(n-1)/2;
int mx=0;
string s[n];
for(int i=0;i<n;i++){
int mxx=mx;
for(int j=0;j<m;j++){
if(col[j]<mc){
if(row[i]<mr){
if(col[j]<mxx||mr-row[i]>=m-j){
s[i]+="+";col[j]++;row[i]++;
}else s[i]+="-";
}else{
s[i]+="-";
}
}else{
s[i]+="-";
}
mx=max(mx,col[j]);
}
}
int ans=0;
for(int i=0;i<n;i++){
if(row[i]>=mr) ans++;
}
for(int j=0;j<m;j++) if(col[j]<=mc) ans++;
cout<<ans<<"\n";
for(int i=0;i<n;i++) cout<<s[i]<<"\n";//cout<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 1: 2 < 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Wrong answer in test 20 2: 11 < 20 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 1: 2 < 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
128 ms |
1316 KB |
Wrong answer in test 97 21: 112 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
108 ms |
1232 KB |
Output is correct |
2 |
Correct |
127 ms |
1924 KB |
Output is correct |
3 |
Correct |
140 ms |
1548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Wrong answer in test 4 1: 2 < 4 |