Submission #158173

#TimeUsernameProblemLanguageResultExecution timeMemory
158173koste4kaRed-blue table (IZhO19_stones)C++14
27 / 100
34 ms1656 KiB
//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #define pb push_back #define F first #define S second #define lll long long #define lld long double using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; const int N = 3e5 + 229; const int M = 1e9 + 7; const lll M2 = 1e9 + 9; const lll mod = 998244353; const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2}; const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1}; const lld eps = 1e-7; const double pi = acos(-1.0); bool a[2000][2000]; int k[2000]; void solve() { int n, m; cin >> n >> m; int ans = max(n, m); for (int i = 0; i < max(n, m); ++i) { k[i] = 0; } if (m > n) { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { a[i][j] = 1; } } int now; for (int i = 0; i < n; ++i) { now = 0; for (int j = 0; j < m; ++j) { if (k[j] + 1 < (n + 1) / 2) { ++now; ++k[j]; a[i][j] = 0; if (now >= m / 2 + 1) { break; } } } if (now >= m / 2 + 1) { ++ans; } } } else { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { a[i][j] = 0; } } int now; for (int j = 0; j < m; ++j) { now = 0; for (int i = 0; i < n; ++i) { if (k[i] + 1 < (m + 1) / 2) { ++now; ++k[i]; a[i][j] = 1; if (now >= n / 2 + 1) { break; } } } if (now >= n / 2 + 1) { ++ans; } } } cout << ans << '\n'; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (a[i][j]) { cout << '-'; } else { cout << '+'; } } cout << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); #endif int t; cin >> t; while (t--) { solve(); } return 0; }
#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...