Submission #599009

#TimeUsernameProblemLanguageResultExecution timeMemory
599009PlurmRed-blue table (IZhO19_stones)C++11
27 / 100
7 ms1476 KiB
#include <bits/stdc++.h> using namespace std; char table[1024][1024]; void build(int n, int m) { // n >= m for sure for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[i][j] = j < (m - 1) / 2 ? '-' : '+'; } table[i][m] = '\0'; } } char tmp[1024][1024]; void transpose(int n, int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { tmp[j][i] = '+' ^ '-' ^ table[i][j]; } } for (int j = 0; j < m; j++) tmp[j][n] = '\0'; for (int i = 0; i < m; i++) { strcpy(table[i], tmp[i]); } } int count(int n, int m) { int cc = 0; for (int i = 0; i < n; i++) { int uc = 0; for (int j = 0; j < m; j++) { if (table[i][j] == '+') uc++; } if (uc > m - uc) cc++; } for (int j = 0; j < m; j++) { int uc = 0; for (int i = 0; i < n; i++) { if (table[i][j] == '-') uc++; } if (uc > n - uc) cc++; } return cc; } int main() { int t; scanf("%d", &t); while (t--) { int n, m; scanf("%d%d", &n, &m); if (n < m) { build(m, n); transpose(m, n); } else { build(n, m); } printf("%d\n", count(n, m)); for (int i = 0; i < n; i++) { printf("%s\n", table[i]); } } return 0; }

Compilation message (stderr)

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