제출 #486864

#제출 시각아이디문제언어결과실행 시간메모리
486864SirCovidThe19thRed-blue table (IZhO19_stones)C++17
38 / 100
48 ms1860 KiB
#include <bits/stdc++.h>
using namespace std;

int n, m; bool flip, ans[1005][1005];

void solve(){
    cin >> n >> m; flip = (n > m);
    if (flip) swap(n, m);

    int H = n / 2 + 1, L = m / 2 + 1;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            ans[i][j] = 0;

    for (int i = 1; i < n - H + 1; i++)
        for (int j = 1; j <= L; j++)
            ans[i][j] = 1;
            
    int lose = (m % 2 == 0) + 1, gain = n - H;
    if (gain - lose > 0)
        for (int i = H + 1; i <= n; i++)
            for (int j = m - L + 1; j <= m; j++)
                ans[i][j] = 1;

    cout<<m + (n - H) + max(gain - lose, 0)<<endl;
    if (flip)
        for (int j = 1; j <= m; j++)
            for (int i = n; i; i--) 
                cout<<(ans[i][j] ? '-' : '+')<<(i == 1 ? "\n" : "");
    else
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++)
                cout<<(ans[i][j] ? '+' : '-')<<(j == m ? "\n" : "");
}

int main(){
    int tc; cin >> tc;
    while (tc--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...