제출 #624339

#제출 시각아이디문제언어결과실행 시간메모리
624339dqhungdlRed-blue table (IZhO19_stones)C++17
100 / 100
34 ms2208 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "debug.hpp" #define debug(x...) cerr << "[" << #x << "] = [", _print(x) #else #define debug(x...) #endif typedef pair<int, int> ii; const int MAX = 1005; int T, m, n; ii C[MAX]; char a[MAX][MAX]; void solve() { cin >> m >> n; bool flipped = false; if (m < n) { flipped = true; swap(m, n); } for (int i = 1; i <= m; i++) { C[i] = {n, i}; for (int j = 1; j <= n; j++) a[i][j] = '+'; } int rs = m; for (int j = 1; j <= n; j++) { sort(C + 1, C + m + 1, greater<>()); bool valid = true; for (int i = 1; i <= m / 2 + 1 && valid; i++) if (C[i].first - 1 > n / 2) { a[C[i].second][j] = '-'; C[i].first--; } else valid = false; rs += valid; } cout << rs << '\n'; if (flipped) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cout << (a[j][i] == '+' ? '-' : '+'); cout << '\n'; } } else { for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) cout << a[i][j]; cout << '\n'; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef DEBUG freopen("../_input", "r", stdin); #endif cin >> T; while (T--) solve(); }
#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...