Submission #868320

#TimeUsernameProblemLanguageResultExecution timeMemory
868320The_SamuraiRed-blue table (IZhO19_stones)C++17
0 / 100
22 ms1368 KiB
// I stand with PALESTINE //#pragma GCC optimize("Ofast,O3") //#pragma GCC target("avx,avx2") #include "bits/stdc++.h" using namespace std; using ll = long long; void out(int n, int m, vector<vector<char>> &a) { int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < m; j++) cnt += a[i][j] == '+'; ans += cnt > m - cnt; } for (int j = 0; j < m; j++) { int cnt = 0; for (int i = 0; i < n; i++) cnt += a[i][j] == '-'; ans += cnt > n - cnt; } cout << ans << '\n'; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j]; cout << '\n'; } } void solve() { int n, m; cin >> n >> m; assert(n == m); vector a(n, vector(m, '+')); if (n < 5) { for (int j = 0; j < (n - 1) / 2; j++) { for (int i = 0; i < n - (n - 1) / 2; i++) { a[i][j] = '-'; } } } else { for (int i = (n - 1) / 2; i <= n / 2; i++) a[i] = vector(m, '-'); for (int i = 0; i < (n - 1) / 2; i++) { for (int j = 0; j < m - 1; j += 2) a[i][j] = '-'; }for (int i = n / 2 + 1; i < n; i++) { for (int j = 1; j < m - 1; j += 2) a[i][j] = '-'; } } out(n, m, a); } int main() { cin.tie(0)->sync_with_stdio(false); #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int q = 1; cin >> q; while (q--) { solve(); // cout << '\n'; } }
#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...