Submission #286843

# Submission time Handle Problem Language Result Execution time Memory
286843 2020-08-31T05:17:13 Z tqbfjotld Red-blue table (IZhO19_stones) C++14
100 / 100
49 ms 1360 KB
#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");
        }
    }
}

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",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 1360 KB Output is correct
2 Correct 40 ms 1188 KB Output is correct
3 Correct 37 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1296 KB Output is correct
2 Correct 36 ms 1144 KB Output is correct
3 Correct 33 ms 1020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 49 ms 1360 KB Output is correct
6 Correct 40 ms 1188 KB Output is correct
7 Correct 37 ms 1144 KB Output is correct
8 Correct 46 ms 1296 KB Output is correct
9 Correct 36 ms 1144 KB Output is correct
10 Correct 33 ms 1020 KB Output is correct
11 Correct 11 ms 512 KB Output is correct
12 Correct 32 ms 1144 KB Output is correct
13 Correct 36 ms 1144 KB Output is correct
14 Correct 29 ms 896 KB Output is correct
15 Correct 43 ms 1272 KB Output is correct
16 Correct 43 ms 1016 KB Output is correct
17 Correct 14 ms 640 KB Output is correct