Submission #286166

#TimeUsernameProblemLanguageResultExecution timeMemory
286166SomeoneUnknownRed-blue table (IZhO19_stones)C++14
38 / 100
6 ms2048 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int T; scanf("%d", &T); for(int t = 0; t < T; ++t){ int r, c; scanf("%d %d", &r, &c); /*if(r == 2 && c == 1){ printf("2\n+\n+\n"); continue; }//*/ char ans[r][c+1]; for(int i = 0; i < r; ++i){ ans[i][c] = '\0'; } for(int i = 0; i < (r-1)/2; ++i){ for(int j = 0; j < (c-1)/2; ++j){ ans[i][j] = '+'; //horizontal } } for(int i = r/2+1; i < r; ++i){ for(int j = 0; j < (c-1)/2; ++j){ ans[i][j] = '-'; //vertical } } for(int i = r/2+1; i < r; ++i){ for(int j = c/2+1; j < c; ++j){ ans[i][j] = '+'; //horizontal } } for(int i = 0; i < (r-1)/2; ++i){ for(int j = c/2+1; j < c; ++j){ ans[i][j] = '-'; //vertical } } for(int i = (r-1)/2; i <= r/2; ++i){ for(int j = 0; j < c; j++){ ans[i][j] = '-'; } } for(int j = 0; j < r; j++){ for(int i = (c-1)/2; i <= c/2; ++i){ ans[j][i] = '+'; } } int ansnum = r+c-4+(r%2)+(c%2); int ans2 = ansnum; if(2 - (r%2) > (c-1)/2){ for(int i = 0; i <= c/2; ++i){ for(int j = (r-1)/2; j <= r/2; ++j){ ans[j][i] = '+'; } } //printf("B"); ans2 = ansnum+2-(r%2)-(c-1)/2; } if(2 - (c%2) > (r-1)/2 && ansnum+2-(c%2)-(r-1)/2>ans2){ for(int i = 0; i <= r/2; ++i){ for(int j = (c-1)/2; j <= c/2; ++j){ ans[i][j] = '-'; } } for(int i = 0; i <= c/2; ++i){ for(int j = (r-1)/2; j <= r/2; ++j){ ans[j][i] = '-'; } } //printf("A"); ans2 = ansnum+2-(c%2)-(r-1)/2; } printf("%d\n", ans2); for(int i = 0; i < r; ++i){ printf("%s\n", ans[i]); } } }

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", &r, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#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...