이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#pragma GCC target ("sse4")
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
#include <cstring>
#include <limits.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll wmod = 998244353;
#define int long long
void solve(){
int n, m;
cin >> n >> m;
char k = '+';
if (n < m){
swap(n, m);
k = '-';
}
char a[n + 1][m + 1];
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
a[i][j] = k;
}
}
if (k == '+')k = '-';
else k = '+';
for (int i = 1; i <= m - i; i++){
for (int j = 1; true; j++){
a[j][i] = k;
if (j > m - j)break;
}
}int ans = 0;
for (int i = 1; i <= n; i++){
int cnt = 0;
for (int j = 1; j <= m; j++){
cnt += (a[i][j] == '+');
}
if (cnt > n - cnt)ans++;
}
for (int j = 1; j <= m; j++){
int cnt = 0;
for (int i = 1; i <= n; i++){
cnt += (a[i][j] == '-');
}
if (cnt > m - cnt)ans++;
}cout << ans << '\n';
if (k == '+'){
for (int i = 1; i <= m; i++){
for (int j = 1; j <= n; j++){
cout << a[i][j];
}cout << '\n';
}
}
else {
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cout << a[i][j];
}cout << '\n';
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
ll T = 1;
cin >> T;
while(T--){
solve();
}
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... |