답안 #334367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334367 2020-12-09T05:11:22 Z limabeans Red-blue table (IZhO19_stones) C++17
43 / 100
2 ms 492 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;
string g[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 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -