#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"
void printVector(vector<pair<int, int>> a){
for (auto x: a) cout << x.second << " ";
cout << endl;
}
void solve(){
int N, M; cin >> N >> M;
int n = N; int m = M;
if (n > m) swap(m, n); // ensures m >= n
int ans = m;
multiset<pair<int, int>> s;
FOR(i,0,m) s.insert({0, i});
int k = (n+1)/2 - 1;
int l = (m)/2+1;
// cout << k << l << endl;
vector<vector<pair<int, int>>> o;
FOR(i,0,n){
vector<pair<int, int>> u;
FOR(j,0,l){
auto x = s.begin();
u.pb(*x);
s.erase(x);
}
bool done = false;
for (auto x: u){
if (x.first >= k) done = true;
}
if (done) break;
o.pb(u);
// printVector(u);
ans++;
for (auto x: u){
s.insert({x.first+1, x.second});
}
}
cout << ans << endl;
// cout << o.size() << endl;
if (N <= M){
// cout << "a" << endl;
vector<vector<int>> grid(N, vector<int>(M, 1));
int i = 0;
for (auto x: o){
for (auto item: x){
// cout << item.second << " ";
grid[i][item.second] = 0;
}
// cout << endl;
i++;
}
FOR(i,0,N){
FOR(j,0,M){
if (grid[i][j]) cout << "-";
else cout << "+";
}
cout << endl;
}
}else{
vector<vector<int>> grid(N, vector<int>(M, 0));
int i = 0;
for (auto x: o){
for (auto item: x){
grid[i][item.second] = 1;
}
i++;
}
FOR(i,0,N){
FOR(j,0,M){
if (grid[i][j]) cout << "+";
else cout << "-";
}
cout << endl;
}
}
}
int32_t main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
int t = 1; cin >> t;
while (t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
in the table A+B is not equal to 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
in the table A+B is not equal to 2 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
764 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
2000 KB |
Output is correct |
2 |
Correct |
63 ms |
9336 KB |
Output is correct |
3 |
Correct |
59 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
in the table A+B is not equal to 2 |
3 |
Halted |
0 ms |
0 KB |
- |