제출 #286843

#제출 시각아이디문제언어결과실행 시간메모리
286843tqbfjotldRed-blue table (IZhO19_stones)C++14
100 / 100
49 ms1360 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int T;
    scanf("%d",&T);
    for (int t = 0; t<T; t++){
        int a,b;
        scanf("%d%d",&a,&b);
        int besta = 0, bestb = b;
        int reqa = b/2+1;
        int reqb = (a-1)/2;
        int curb = b;
        for (int x = 1; x<=a; x++){
            while (x*(reqa-(b-curb))>reqb*curb){
                curb--;
            }
            if (x+curb>besta+bestb){
                besta = x;
                bestb = curb;
            }
        }
        printf("%d\n",besta+bestb);
        int curC = b-bestb;
        for (int y = 0; y<besta; y++){
            int cn = reqa-(b-bestb);
            for (int x = 0; x<b; x++){
                if (x<b-bestb){
                    printf("+");
                }
                else if ((curC+cn>=b && (curC+cn-bestb>x||x>=curC))||(curC+cn<b&&(x>=curC && x<curC+cn))){
                    printf("+");
                }
                else{
                    printf("-");
                }
            }
            curC+=cn;
            if (curC>=b) curC-=bestb;
            printf("\n");
        }
        for (int x = besta; x<a; x++){
            for (int y = 0; y<b; y++){
                printf("-");
            }
            printf("\n");
        }
    }
}

컴파일 시 표준 에러 (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",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
#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...