답안 #602386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
602386 2022-07-23T02:46:46 Z Hanksburger Red-blue table (IZhO19_stones) C++17
100 / 100
24 ms 2264 KB
#include <bits/stdc++.h>
using namespace std;
bool ans[1005][1005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        bool b=0;
        if (n>m)
        {
            swap(n, m);
            b=1;
        }
        int k=n-n/2-1;
        int l=min(n, k*m/(m/2+1));
        cout << l+m << '\n';
        if (l)
        {
            for (int j=0; j<m; j++)
            {
                int L=k*j%l, R=k*(j+1)%l;
                if (L<R)
                    for (int i=0; i<l; i++)
                        ans[i][j]=(L<=i && i<R);
                else
                    for (int i=0; i<l; i++)
                        ans[i][j]=(L<=i || i<R);
                for (int i=l; i<n; i++)
                    ans[i][j]=0;
            }
        }
        else
            for (int i=0; i<n; i++)
                for (int j=0; j<m; j++)
                ans[i][j]=0;
        if (b)
        {
            for (int j=0; j<m; j++)
            {
                for (int i=0; i<n; i++)
                    cout << (ans[i][j]?'-':'+');
                cout << '\n';
            }
        }
        else
        {
            for (int i=0; i<n; i++)
            {
                for (int j=0; j<m; j++)
                    cout << (ans[i][j]?'+':'-');
                cout << '\n';
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1372 KB Output is correct
2 Correct 22 ms 1868 KB Output is correct
3 Correct 19 ms 1848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1416 KB Output is correct
2 Correct 20 ms 1780 KB Output is correct
3 Correct 17 ms 1592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 22 ms 1372 KB Output is correct
6 Correct 22 ms 1868 KB Output is correct
7 Correct 19 ms 1848 KB Output is correct
8 Correct 22 ms 1416 KB Output is correct
9 Correct 20 ms 1780 KB Output is correct
10 Correct 17 ms 1592 KB Output is correct
11 Correct 6 ms 592 KB Output is correct
12 Correct 16 ms 1600 KB Output is correct
13 Correct 24 ms 1548 KB Output is correct
14 Correct 13 ms 1236 KB Output is correct
15 Correct 22 ms 2264 KB Output is correct
16 Correct 20 ms 1748 KB Output is correct
17 Correct 10 ms 1088 KB Output is correct