Submission #990476

#TimeUsernameProblemLanguageResultExecution timeMemory
990476ToniBRed-blue table (IZhO19_stones)C++17
15 / 100
43 ms1884 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int N = 1001; int t, n, m; bool ans[N][N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> t; while (t--) { cin >> n >> m; bool swp = 0; if (n > m) { swap(n, m); swp = 1; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) ans[i][j] = 0; } int sum = m, mx = (n - 1) / 2; multiset<pii> ms; queue<pii> tmp; for (int i = 0; i < m; ++i) ms.insert({0, i}); for (int i = 0; i < n; ++i) { vector<int> cols; bool bad = 0; while (cols.size() < m / 2 + 1) { auto it = ms.begin(); int idx = (*it).second, cnt = (*it).first; ms.erase(it); if (cnt == mx) { bad = 1; break; } cols.push_back(idx); tmp.push({cnt + 1, idx}); } if (bad) break; for (int j : cols) ans[i][j] = 1; while (!tmp.empty()) { ms.insert(tmp.front()); tmp.pop(); } ++sum; } cout << sum << '\n'; if (swp) { for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { if (ans[i][j]) cout << '-'; else cout << '+'; } cout << '\n'; } } else { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (ans[i][j]) cout << '+'; else cout << '-'; } cout << '\n'; } } } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:34:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |    while (cols.size() < m / 2 + 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...