Submission #519113

#TimeUsernameProblemLanguageResultExecution timeMemory
519113Dasha_GnedkoRed-blue table (IZhO19_stones)C++17
27 / 100
59 ms1868 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/detail/standard_policies.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("Ofast") //#pragma GCC target("avx2") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4") 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>; mt19937 gen(time(0)); #define ll long long #define ld long double #define pb push_back #define F first #define S second #define TIME clock() * 1.0 / CLOCKS_PER_SEC #define sz(a) int32_t(a.size()) #define endl '\n' //#define int long long const int N = 5e5 + 100; const int M = 31; const int mod = 1e9 + 7; const ll inf = 1e18 + 7; int calc(vector < vector < int > > a) { int ans = 0; for(int i = 0; i < sz(a); i++) { int x = 0, y = 0; for(int j = 0; j < sz(a[i]); j++) { if (a[i][j]) x++; else y++; } ans += (x > y); } for(int j = 0; j < sz(a[0]); j++) { int x = 0, y = 0; for(int i = 0; i < sz(a); i++) { if (a[i][j]) y++; else x++; } ans += (x > y); } return ans; } void solve() { int n, m; cin >> n >> m; vector < vector < int > > a(n, vector < int > (m, 0)), b = a, c = a, d(n, vector < int > (m, 1)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) if (j % 2 == 0) a[i][j] = 1; if (m % 2 == 0) { for(int i = 0; i < n; i++) a[i][m - 1] = 1; } for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) if (i % 2) b[i][j] = 1; if (n % 2 == 0) { for(int j = 0; j < m; j++) b[0][j] = 1; } if (calc(b) > calc(a)) a = b; if (calc(c) > calc(a)) a = c; if (calc(d) > calc(a)) a = d; cout << calc(a) << endl; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if (a[i][j]) cout << "+"; else cout << "-"; } cout << endl; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(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 // LOCAL int T; 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...