답안 #690876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690876 2023-01-30T13:45:31 Z Nuraly_Serikbay Red-blue table (IZhO19_stones) C++14
27 / 100
1 ms 340 KB
/* Speech to the young */
 
//#include <bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
 
using namespace std;
 
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define YOSIK() ios_base::sync_with_stdio(0),cin.tie(0)
#define int long long
#define pans cout << "\n------ans-------\n" 
 
const int N = 1e6 + 10;
const int INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const int P = 31;

int n, m; 

void Solution () {
	cin >> n >> m;
	if (n <= m && n <= 4) {
		cout << (n / 2 - (1 - (n % 2))) + m << '\n';
		for (int i = 1; i <= n; ++ i) {
			for (int j = 1; j <= m; ++ j) {
				if (i <= n / 2 + 1) cout << "-";
				else cout << '+';
			}
			cout << '\n';
		}
		return;
	}
	if (n >= m && m <= 4) {
		cout << (m / 2 - (1 - (m % 2))) + n << '\n';
		for (int i = 1; i <= n; ++ i) {
			for (int j = 1; j <= m; ++ j) {
				if (j <= m / 2 + 1) cout << "+";
				else cout << '-';
			}
			cout << '\n';
		}
		return;
	}
	if (n == 5) {
		cout << (m / 2 - (1 - (m % 2))) * 2 + n - 1 << '\n';
		int cnt1 = 0, cnt2 = 0, mx = m / 2 - (1 - (m % 2));
		for (int i = 1; i <= n; ++ i) {
			cnt1 = cnt2 = 0;
			for (int j = 1; j <= m; ++ j) {
				if (i == 3) cout << "-";
				else if (j % 2 == 1) {
					if (i <= 3 && cnt1 < mx) cout << "-";
					else cout << "+";
					cnt1 ++;
				} else if (j % 2 == 0) {
					if (i < 3 || cnt2 >= mx) cout << "+";
					else cout << '-'; 
					cnt2 ++;
					
				}
			}
			cout << '\n';
		}
		return;
	}
	if (m == 5) {
		cout << (n / 2 - 1 + (n % 2)) * 2 + m - 1 << '\n';
		int cnt1 = 0, cnt2 = 0, mx = n / 2 - 1 + (n % 2);
		for (int i = 1; i <= n; ++ i) {
			if (i % 2 == 1) cnt1 ++;
			else cnt2 ++;
			
			for (int j = 1; j <= m; ++ j) {
				if (j == 3) cout << '+';
				else if (j < 3) {
					if (i % 2 == 1 && cnt1 <= mx) cout << '+'; 
					else cout << '-';
				} else if (j > 3) {
					if (i % 2 == 0 && cnt2 <= mx) cout << "+";
					else cout << '-'; 
				}
			}
			cout << '\n';
		}
	}
	return;
}
 
signed main () {
	YOSIK();
//	precalc();
	int T = 1; 
	cin >> T;
	while (T --) Solution ();
	exit (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 212 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 212 KB Output is correct
4 Incorrect 1 ms 340 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Wrong answer
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 212 KB Output is correct
4 Incorrect 1 ms 340 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -