Submission #883386

#TimeUsernameProblemLanguageResultExecution timeMemory
883386boris_mihovRed-blue table (IZhO19_stones)C++17
0 / 100
3 ms1884 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cstring> #include <cassert> #include <vector> #include <bitset> #include <queue> #include <set> typedef long long llong; const int MAXN = 1000 + 10; const int MAXLOG = 20; const llong INF = 4e18; const int INTINF = 2e9; int n, m; char t[MAXN][MAXN]; int countMAX[MAXN]; std::vector <int> canAdd; bool reversed; int answer; void solve() { if (n > m) { std::swap(n, m); } int countLeft = n * m - m * ((n + 2) / 2); int rows = countLeft / ((m + 2) / 2); answer = m + rows; for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { t[i][j] = '+'; } } for (int i = 1 ; i <= rows ; ++i) { countMAX[i] = m - (m + 2) / 2; canAdd.push_back(i); } for (int i = rows + 1 ; i <= n ; ++i) { for (int col = 1 ; col <= m ; ++col) { t[i][col] = '-'; } } for (int col = 1 ; col <= m ; ++col) { int needed = (n + 2) / 2 - (n - rows); assert(canAdd.size() >= needed); for (int i = 0 ; i < needed ; ++i) { t[canAdd[i]][col] = '-'; countMAX[canAdd[i]]--; } int count = 0; for (int i = 0 ; count < needed ; ++i) { count++; if (countMAX[canAdd[i]] == 0) { std::swap(canAdd[i], canAdd.back()); canAdd.pop_back(); --i; continue; } } } } void print() { std::cout << answer << '\n'; if (reversed) { for (int i = 1 ; i <= m ; ++i) { for (int j = 1 ; j <= n ; ++j) { std::cout << t[j][i]; } std::cout << '\n'; } } else { for (int i = 1 ; i <= n ; ++i) { std::cout << t[i] + 1 << '\n'; } } } void input() { std::cin >> n >> m; } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int tests; int main() { fastIOI(); std::cin >> tests; while (tests--) { input(); solve(); print(); } return 0; }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from stones.cpp:5:
stones.cpp: In function 'void solve()':
stones.cpp:61:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         assert(canAdd.size() >= needed);
      |                ~~~~~~~~~~~~~~^~~~~~~~~
#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...