# include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 5e5 + 25;
const ll inf = 1e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
int n, m;
int cnt (vector < vector <int> >& a)
{
int res = 0;
for (int i = 0; i < n; ++i)
{
int cnt[2] = {0};
for (int j = 0; j < m; ++j)
{
cnt[a[i][j]]++;
}
if (cnt[1] >= m / 2 + 1)
{
res++;
}
}
for (int j = 0; j < m; ++j)
{
int cnt[2] = {0};
for (int i = 0; i < n; ++i)
{
cnt[a[i][j]]++;
}
if (cnt[0] >= n / 2 + 1)
{
res++;
}
}
return res;
}
void print (vector < vector <int> > a)
{
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (a[i][j] == 0) cout << '-';
else cout << '+';
}
cout << nl;
}
cout << nl;
}
void ma1n (/* SABR */)
{
cin >> n >> m;
if (n >= m)
{
vector < vector <int> > a(n, vector <int>(m, 0));
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (j < m / 2 + 1)
{
a[i][j] = 1;
}
else
{
a[i][j] = 0;
}
}
}
cout << cnt(a) << nl;
print(a);
}
else
{
vector < vector <int> > a(n, vector <int>(m, 0));
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (i < n / 2 + 1)
{
a[i][j] = 0;
}
else
{
a[i][j] = 1;
}
}
}
cout << cnt(a) << nl;
print(a);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int ttt = 1;
cin >> ttt;
for (int test = 1; test <= ttt; ++test)
{
// cout << "Case " << test << ":" << ' ';
ma1n();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
1456 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
1552 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |