Submission #1093925

#TimeUsernameProblemLanguageResultExecution timeMemory
1093925stdfloatRed-blue table (IZhO19_stones)C++17
100 / 100
46 ms2388 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ff first #define ss second #define pii pair<int, int> #define all(v) (v).begin(), (v).end() void solve() { int n, m; cin >> n >> m; int ans = max(n, m); vector<vector<char>> a; if (n < m) { a.assign(n, vector<char>(m, '-')); vector<int> vis(m); for (int i = 0; i < n; i++) { vector<pii> v; for (int j = 0; j < m; j++) v.push_back({vis[j], j}); sort(v.begin(), v.end()); bool tr = true; for (int j = 0; j < (m >> 1) + 1; j++) { if (v[j].ff == (n - 1 >> 1)) { tr = false; break; } vis[v[j].ss]++; a[i][v[j].ss] = '+'; } if (!tr) break; ans++; } } else { a.assign(n, vector<char>(m, '+')); vector<int> vis(n); for (int i = 0; i < m; i++) { vector<pii> v; for (int j = 0; j < n; j++) v.push_back({vis[j], j}); sort(v.begin(), v.end()); bool tr = true; for (int j = 0; j < (n >> 1) + 1; j++) { if (v[j].ff == (m - 1 >> 1)) { tr = false; break; } vis[v[j].ss]++; a[v[j].ss][i] = '-'; } if (!tr) break; ans++; } } cout << ans << '\n'; for (auto i : a) { for (auto j : i) cout << j; cout << '\n'; } cout << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) solve(); }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:33:23: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   33 |     if (v[j].ff == (n - 1 >> 1)) {
      |                     ~~^~~
stones.cpp:59:23: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   59 |     if (v[j].ff == (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...