//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define F first
#define S second
#define ll long long
#define lld long double
#define pii pair < int, int >
using namespace std;
//template <typename T>
//using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N = 3e5 + 229;
const int M = 1e9 + 7;
const ll M2 = 1e9 + 9;
const int mod = 998244353;
const int Sx[8] = {1, 1, -1, -1, -2, 2, 2, -2};
const int Sy[8] = {-2, 2, 2, -2, 1, 1, -1, -1};
const lld eps = 1e-7;
const double pi = acos(-1.0);
//mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// srand(time(0));
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
int t;
cin >> t;
while(t--) {
int n, m;
cin >> n >> m;
if(n <= m) {
int ans = m;
char a[n][m];
pair <int, int> k[m];
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
a[i][j] = '-';
k[j].F = 0;k[j].S = j;
}
}
int pos = m / 2 + 1;
int cnt = n / 2;
if(n % 2 == 0)cnt--;
for(int z = 0; z < n; ++z) {
if(k[pos - 1].F >= cnt)break;
ans++;
for(int i = 0; i < pos; ++i) {
a[z][k[i].S] = '+';
k[i].F++;
}
sort(k, k + n);
}
cout << ans << endl;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j)
cout << a[i][j];
cout << endl;
}
}
else {
int ans = n;
char a[n][m];
pair <int, int> k[n];
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
a[i][j] = '+';
}
k[i].F = 0;k[i].S = i;
}
int pos = n / 2 + 1;
int cnt = m / 2;
if(m % 2 == 0)cnt--;
for(int z = 0; z < m; ++z) {
if(k[pos + 1].F >= cnt)break;
ans++;
for(int i = 0; i < pos; ++i) {
a[k[i].S][z] = '-';
k[i].F++;
}
sort(k, k + m);
}
cout << ans << endl;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j)
cout << a[i][j];
cout << endl;
}
}
}}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
1400 KB |
in the table A+B is not equal to 118 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
1376 KB |
Output is correct |
2 |
Correct |
40 ms |
1628 KB |
Output is correct |
3 |
Correct |
38 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Wrong answer in test 4 3: 4 < 5 |