이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 998244353
#define INF 1000000000000000000
#define EPS 1e-10
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while(t--) {
int n, m, ans = 0;
bool swp = false;
cin >> n >> m;
if(n > m) {
swap(n, m);
swp = true;
}
int a[n][m], idx = 0, cnt = 0, num = (n-ceil((n+1)/2.0))*m;
memset(a, 0, sizeof(a));
for(int i = 0; i < n;) {
for(int j = 0; j < m/2+1; j++) {
if(cnt == num) goto nxt;
a[i][idx] = 1; // red
idx = (idx+1)%m;
cnt++;
if(j == m/2) i++;
}
}
nxt:;
for(int i = 0; i < n; i++) {
cnt = 0;
for(int j = 0; j < m; j++) {
if(a[i][j] == 1) cnt++;
}
if(cnt > m-cnt) ans++;
}
for(int j = 0; j < m; j++) {
cnt = 0;
for(int i = 0; i < n; i++) {
if(a[i][j] == 0) cnt++;
}
if(cnt > n-cnt) ans++;
}
cout << ans << '\n';
if(swp) {
for(int j = 0; j < m; j++) {
for(int i = 0; i < n; i++) {
if(a[i][j] == 1) cout << '-';
else cout << '+';
}
cout << '\n';
}
} else {
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(a[i][j] == 1) cout << '+';
else cout << '-';
}
cout << '\n';
}
}
}
}
# | 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... |