답안 #870647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870647 2023-11-08T16:49:26 Z KiaRez Red-blue table (IZhO19_stones) C++17
100 / 100
19 ms 5212 KB
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

const int N = 1e6+23, lg = 21;
ll Mod = 998244353;

inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
    ll ans = 1;
    a=MOD(a, mod);
    while (b) {
        if (b & 1) ans = MOD(ans*a, mod);
        b >>= 1;
        a = MOD(a*a, mod);
    }
    return ans;
}

int t, n, m, a[1005][1005];
int main () {
	ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>t;
	while(t--) {
		cin>>n>>m;
		int cnt=0, x=0, ans=0, nm=0;
		if(n < m) {
			swap(n,m);nm=1;
		}
		for(int i=0; i<n; i++) fill(a[i], a[i]+m, 1);
		ans = n;

		for(int i=0; i<(m-1)/2; i++) {
			for(int j=0; j<n; j++) {
				a[j][x] = -1;
				cnt++;
				if(cnt == n/2+1) {
					x++;
					cnt=0; ans++;
				}
			}
		}

		cout<<ans<<endl;
		if(nm == 0) {
			for(int i=0; i<n; i++) {
				for(int j=0; j<m; j++) {
					cout<<(a[i][j]<0 ? '-' : '+');
				}
				cout<<endl;
			}
		} else {
			for(int i=0; i<m; i++) {
				for(int j=0; j<n; j++) {
					cout<<(a[j][i]>0 ? '-' : '+');
				}
				cout<<endl;
			}
		}
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 3676 KB Output is correct
2 Correct 18 ms 4612 KB Output is correct
3 Correct 16 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3676 KB Output is correct
2 Correct 15 ms 3928 KB Output is correct
3 Correct 13 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 19 ms 3676 KB Output is correct
6 Correct 18 ms 4612 KB Output is correct
7 Correct 16 ms 4952 KB Output is correct
8 Correct 18 ms 3676 KB Output is correct
9 Correct 15 ms 3928 KB Output is correct
10 Correct 13 ms 3416 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 19 ms 4252 KB Output is correct
13 Correct 15 ms 4700 KB Output is correct
14 Correct 12 ms 3932 KB Output is correct
15 Correct 19 ms 5212 KB Output is correct
16 Correct 14 ms 4700 KB Output is correct
17 Correct 7 ms 3416 KB Output is correct