답안 #486864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486864 2021-11-13T04:52:31 Z SirCovidThe19th Red-blue table (IZhO19_stones) C++17
38 / 100
48 ms 1860 KB
#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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Incorrect 4 ms 332 KB Wrong answer in test 38 5: 40 < 41
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 1336 KB Output is correct
2 Correct 36 ms 1860 KB Output is correct
3 Correct 34 ms 1860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 1424 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Incorrect 4 ms 332 KB Wrong answer in test 38 5: 40 < 41