Submission #599095

#TimeUsernameProblemLanguageResultExecution timeMemory
599095M_WRed-blue table (IZhO19_stones)C++17
0 / 100
90 ms1356 KiB
#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 (stderr)

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 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...