답안 #334368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334368 2020-12-09T05:12:01 Z limabeans Red-blue table (IZhO19_stones) C++17
100 / 100
37 ms 2412 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl








const int maxn = 1e3+10;


int n, m;
char g[maxn][maxn];

void solve() {
    cin>>n>>m;
    bool flip = false;
    if (n<m) {
	flip = true;
	swap(n,m);
    }

    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    g[i][j] = '+';
	}
    }

    int col = 0;
    int drop = n/2+1;

    for (int j=0; j<(m-1)/2; j++) {
	for (int i=0; i<n; i++) {
	    g[i][col] = '-';
	    if (--drop == 0) {
		col++;
		drop = n/2+1;
	    }
	}
    }

    cout<<n+col<<"\n";
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    if (flip) g[i][j]=char('+'+'-'-g[i][j]);
	}
    }

    if (flip) {
	swap(n,m);
	for (int i=0; i<n; i++) {
	    for (int j=0; j<m; j++) {
		cout<<g[j][i];
	    }
	    cout<<"\n";
	}
    } else {
	for (int i=0; i<n; i++) {
	    for (int j=0; j<m; j++) {
		cout<<g[i][j];
	    }
	    cout<<"\n";
	}
    }
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    
    int t;
    cin>>t;
    while (t--) {
	solve();
    }
    
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1516 KB Output is correct
2 Correct 37 ms 2156 KB Output is correct
3 Correct 30 ms 2156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 1644 KB Output is correct
2 Correct 29 ms 1900 KB Output is correct
3 Correct 33 ms 1644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 36 ms 1516 KB Output is correct
6 Correct 37 ms 2156 KB Output is correct
7 Correct 30 ms 2156 KB Output is correct
8 Correct 35 ms 1644 KB Output is correct
9 Correct 29 ms 1900 KB Output is correct
10 Correct 33 ms 1644 KB Output is correct
11 Correct 9 ms 620 KB Output is correct
12 Correct 28 ms 1900 KB Output is correct
13 Correct 30 ms 2028 KB Output is correct
14 Correct 22 ms 1772 KB Output is correct
15 Correct 37 ms 2412 KB Output is correct
16 Correct 28 ms 2028 KB Output is correct
17 Correct 12 ms 1388 KB Output is correct