제출 #1190938

#제출 시각아이디문제언어결과실행 시간메모리
1190938lovrotRed-blue table (IZhO19_stones)C++20
100 / 100
129 ms5192 KiB
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> #define deb(...) fprintf(stderr, __VA_ARGS__) using namespace std; const int N = 1010; const int Z[2] = {'-', '+'}; int n, m; int ans[N][N]; void task() { scanf("%d%d", &n, &m); memset(ans, 0, sizeof(ans)); printf("%d\n", max(m + m * (n - n / 2 - 1) / (m / 2 + 1), n + n * (m - m / 2 - 1) / (n / 2 + 1))); if(m + m * (n - n / 2 - 1) / (m / 2 + 1) > n + n * (m - m / 2 - 1) / (n / 2 + 1)) { for(int i = 0, j = 0; i < m * (n - n / 2 - 1) / (m / 2 + 1); ++i) { for(int k = 0; k < (m / 2 + 1); ++k, j = (j + 1) % m) { ans[i][j] ^= 1; } } for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) printf("%c", Z[ans[i][j]]); printf("\n"); } } else { for(int i = 0, j = 0; i < n * (m - m / 2 - 1) / (n / 2 + 1); ++i) { for(int k = 0; k < (n / 2 + 1); ++k, j = (j + 1) % n) { ans[j][i] ^= 1; } } for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) printf("%c", Z[1 ^ ans[i][j]]); printf("\n"); } } } int main() { int t; scanf("%d", &t); for(; t--; ) task(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

stones.cpp: In function 'void task()':
stones.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d%d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~
#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...