Submission #1093905

#TimeUsernameProblemLanguageResultExecution timeMemory
1093905stdfloatRed-blue table (IZhO19_stones)C++17
17 / 100
2068 ms604 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define all(v) (v).begin(), (v).end() void solve() { int n, m; cin >> n >> m; int mx = 0; for (int mk = 0; mk < 1 << n * m; mk++) { vector<vector<int>> a(n, vector<int>(m)); for (int i = 0; i < n * m; i++) a[i / m][i % m] = (mk >> i) & 1; int scr = 0; for (int i = 0; i < n; i++) scr += (count(all(a[i]), 0) > count(all(a[i]), 1)); for (int i = 0; i < m; i++) { vector<int> cnt(2); for (int j = 0; j < n; j++) cnt[a[j][i]]++; scr += (cnt[1] > cnt[0]); } mx = max(mx, scr); } cout << mx << '\n'; assert(mx == max(n, m) + (min(n, m) - 1 >> 1)); for (int mk = 0; mk < 1 << n * m; mk++) { vector<vector<int>> a(n, vector<int>(m)); for (int i = 0; i < n * m; i++) a[i / m][i % m] = (mk >> i) & 1; int scr = 0; for (int i = 0; i < n; i++) scr += (count(all(a[i]), 0) > count(all(a[i]), 1)); for (int i = 0; i < m; i++) { vector<int> cnt(2); for (int j = 0; j < n; j++) cnt[a[j][i]]++; scr += (cnt[1] > cnt[0]); } if (scr == mx) { for (auto i : a) { for (auto j : i) cout << (j ? '-' : '+'); cout << '\n'; } return; cout << '\n'; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) solve(); }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stones.cpp:1:
stones.cpp: In function 'void solve()':
stones.cpp:34:38: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   34 |  assert(mx == max(n, m) + (min(n, m) - 1 >> 1));
      |                            ~~~~~~~~~~^~~
#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...