Submission #286210

#TimeUsernameProblemLanguageResultExecution timeMemory
286210SomeoneUnknownRed-blue table (IZhO19_stones)C++14
100 / 100
9 ms2304 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'; } if(r > c){ for(int i = 0; i < r; ++i){ for(int j = 0; j < c; ++j){ ans[i][j] = '+'; } } long long bestaddi = (long long) r * (((long long) c - 1) / 2) / (((long long) r) / 2 + 1); long long cur = 0; for(int i = 0; i < r; ++i){ for(int j = 0; j < (c - 1) / 2; ++j){ ans[i][cur] = '-'; cur++; cur %= bestaddi; } } printf("%lld\n", r+bestaddi); for(int i = 0; i < r; ++i){ printf("%s\n", ans[i]); } }else{ for(int i = 0; i < r; ++i){ for(int j = 0; j < c; ++j){ ans[i][j] = '-'; } } long long bestaddi = (long long) c * (((long long) r - 1) / 2) / (((long long) c) / 2 + 1); long long cur = 0; for(int i = 0; i < c; ++i){ for(int j = 0; j < (r - 1) / 2; ++j){ ans[cur][i] = '+'; cur++; cur %= bestaddi; } } printf("%lld\n", c+bestaddi); 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...