# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1183812 | asdfghjk | Red-blue table (IZhO19_stones) | C++20 | 13 ms | 1352 KiB |
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define con continue
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
const ll N = 1000 + 5;
const ll inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
int a[N][N];
void solve(){
int n,m;cin >> n >> m;
if(n <= m){
int res = (m + ((n - 1) / 2));
int d = m - ((m - 1) / 2);
int w = (d - (m - d));
int opr = (m - w);
d = (n - 1) / 2;
opr += (d * 2);
cout << max(opr,res) << '\n';
if(opr > res){
for(int i = 1;i <= (n - (d * 2));i++){
for(int j = 1;j <= m;j++){
cout << '-';
}
cout << '\n';
}
int mr = m - ((m - 1) / 2);
for(int i = 1;i <= d;i++){
for(int j = 1;j <= m;j++){
if(j <= mr){
cout << '+';
}
else cout << '-';
}
cout << '\n';
}
for(int i = 1;i <= d;i++){
for(int j = 1;j <= m;j++){
if(j + mr <= m){
cout << '-';
}
else cout << '+';
}
cout << '\n';
}
}
else{
int q= ((n - 1) / 2);
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(i + q <= n){
cout << '-';
}
else cout << '+';
}
cout << '\n';
}
}
}
else{
//n > m
int res = n + ((m - 1) / 2);
int q = (2 - (n % 2));
int c = ((m - 1) / 2);
int d = ((n - 1) / 2);
int opr = (n - q) + (c * 2);
cout << max(res,opr) << '\n';
if(opr >= res){
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(j + (c * 2) <= m){
cout << '+';
}
else if(j +c <= m){
if(i <= d){
cout << '+';
}
else cout << '-';
}
else{
if(i <= n - d){
cout << '-';
}
else cout << '+';
}
}
cout << '\n';
}
}
else{
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
if(j <= m - c)cout << '+';
else cout << '-';
}
cout << '\n';
}
}
}
}
//++++--
//++++--
//++++--
//++----
//++----
//++--++
//++--++
//++--++
//
//6 + 4 = 10
//
//++++--
//++++--
//++++--
//++++--
//++++--
//++++--
//++++--
//++++--
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;cin >> t;
while(t--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |