이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |