Submission #344068

#TimeUsernameProblemLanguageResultExecution timeMemory
344068NurlykhanRed-blue table (IZhO19_stones)C++17
17 / 100
2083 ms620 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1024; int t; int n, m; bool a[N][N], ans[N][N]; int cnt() { int res = 0; for (int i = 0; i < n; i++) { int s = 0; for (int j = 0; j < m; j++) { if (a[i][j]) s++; else s--; } if (s > 0) res++; } for (int j = 0; j < m; j++) { int s = 0; for (int i = 0; i < n; i++) { if (a[i][j]) s++; else s--; } if (s < 0) res++; } return res; } void solve() { int mx = 0; for (int mask = 0; mask < (1 << (n * m)); mask++) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if ((mask >> (i * m + j)) % 2) { a[i][j] = 1; } else { a[i][j] = 0; } } } int cur = cnt(); if (cur > mx) { mx = cur; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ans[i][j] = a[i][j]; } } } } printf("%d\n", mx); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (ans[i][j]) printf("+"); else printf("-"); } printf("\n"); } } int main() { scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); solve(); } return 0; }

Compilation message (stderr)

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