Submission #502604

#TimeUsernameProblemLanguageResultExecution timeMemory
502604stanislavpolynRed-blue table (IZhO19_stones)C++17
0 / 100
24 ms1412 KiB
#include <bits/stdc++.h> #define fr(i, a, b) for(int i = (a); i <= (b); ++i) #define rf(i, a, b) for(int i = (a); i >= (b); --i) #define fe(x, y) for(auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define pw(x) (1LL << (x)) using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template<typename T> bool umn(T& a, T b) { return (a > b ? (a = b, 1) : 0); } template<typename T> bool umx(T& a, T b) { return (a < b ? (a = b, 1) : 0); } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename T> using ve = vector<T>; const int N = 1e3 + 5; int n, m; char a[N][N]; int cntR[N]; int cntB[N]; void solve() { cin >> n >> m; fr(i, 1, n) cntR[i] = 0; fr(i, 1, m) cntB[i] = 0; int needR = m / 2 + 1; int needB = n / 2 + 1; fr(i, 1, n) { fr(j, 1, m) { if(cntR[i] < needR && cntB[j] + (n - i) >= needB) { cntR[i]++; a[i][j] = 'R'; } else { a[i][j] = 'B'; cntB[j]++; } } } int score = 0; fr(i, 1, n) score += cntR[i] >= needR; fr(i, 1, m) score += cntB[i] >= needB; cout << score << "\n"; fr(i, 1, n) { fr(j, 1, m) { cout << (a[i][j] == 'R' ? '+' : '-'); } cout << "\n"; } } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); #else // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); #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...