답안 #308769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308769 2020-10-01T21:58:48 Z nikatamliani Red-blue table (IZhO19_stones) C++14
15 / 100
45 ms 1664 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int T = 1;
    cin >> T;
    while(T--) {
        int n, m, cntI = 0, best = 0;
        cin >> n >> m; 
        bool ans[n + 1][m + 1];
        memset(ans, 0, sizeof ans);
        for(int i = 0; i <= n; ++i) {
            int sum = i * (m / 2 + 1);
            int cnt_less = m - sum % m;
            int cnt_more = sum % m;
            int less = sum / n;
            int more = less + 1; 
            int rem = n * m - sum, now = i;
            int can = (n - 1) / 2, have = n - can;
            sum = max(0, sum - can * m);
            now += m - (sum + have - 1) / have;
            if(best < now) {
                best = now, cntI = i;
            }
        }
        int prev = 1;
        for(int i = 1; i <= cntI; ++i) {
            int cnt = m / 2 + 1;
            for(int j = prev; cnt--; j = (j == m ? 1 : j + 1)) {
                prev = (j == m ? 1 : j + 1);
                ans[i][j] = 1;
            }
        }
        cout << best << '\n';
        vector < int > row(n + 1), col(m + 1);
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j) {
                if(ans[i][j]) {
                    cout << '+';
                    ++row[i]; --col[j];
                } else {
                    cout << '-';
                    --row[i]; ++col[j];
                }
            }
            cout << '\n';
        }
    }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:13:17: warning: unused variable 'cnt_less' [-Wunused-variable]
   13 |             int cnt_less = m - sum % m;
      |                 ^~~~~~~~
stones.cpp:14:17: warning: unused variable 'cnt_more' [-Wunused-variable]
   14 |             int cnt_more = sum % m;
      |                 ^~~~~~~~
stones.cpp:16:17: warning: unused variable 'more' [-Wunused-variable]
   16 |             int more = less + 1;
      |                 ^~~~
stones.cpp:17:17: warning: unused variable 'rem' [-Wunused-variable]
   17 |             int rem = n * m - sum, now = i;
      |                 ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 1324 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1400 KB Output is correct
2 Correct 35 ms 1664 KB Output is correct
3 Correct 32 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB in the table A+B is not equal to 5