Submission #599095

# Submission time Handle Problem Language Result Execution time Memory
599095 2022-07-19T10:03:03 Z M_W Red-blue table (IZhO19_stones) C++17
0 / 100
90 ms 1356 KB
#include <bits/stdc++.h>
using namespace std;
char a[1010][1010];
int main(){
    int T;
    scanf("%d", &T);
    while(T--){
        int N, M, state = 0;
        scanf("%d %d", &N, &M);
        if(N > M){
            state = 1;
            swap(N, M);
        }

        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= M; j++) a[i][j] = state ? '+' : '-';
        }
        for(int i = 1; i <= N - (2 - N % 2); i++){
            for(int j = (i - 1) % 2; j <= M; j+= 2){
                a[i][j] = state ? '-' : '+';
            }
        }

        int ans = 0;
        for(int i = 1; i <= N; i++){
            int red = 0, blue = 0;
            for(int j = 1; j <= M; j++){
                if(a[i][j] == '+') red++;
                else blue++;
            }
            if(state && blue > red) ans++;
            else if(!state && red > blue) ans++;
        }

        for(int i = 1; i <= M; i++){
            int red = 0, blue = 0;
            for(int j = 1; j <= N; j++){
                if(a[j][i] == '+') red++;
                else blue++;
            }
            if(!state && blue > red) ans++;
            else if(state && red > blue) ans++;
        }

        printf("%d\n", ans);
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= M; j++){
                printf("%c", state ? a[j][i] : a[i][j]);
            }
            printf("\n");
        }
    }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%d", &T);
      |     ~~~~~^~~~~~~~~~
stones.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d %d", &N, &M);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 1356 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1352 KB Wrong answer in test 24 24: 24 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong answer
3 Halted 0 ms 0 KB -