Submission #992853

#TimeUsernameProblemLanguageResultExecution timeMemory
992853NValchanovRed-blue table (IZhO19_stones)C++17
15 / 100
44 ms2384 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const int MAXN = 1e3 + 10; int n, m; bool table[MAXN][MAXN]; int ans; bool sw; void read() { cin >> n >> m; if(n < m) { swap(n, m); sw = true; } } void solve() { memset(table, 1, sizeof(table)); ans = n; int j = 1; int placed = 0; for(int k = 1; k <= (m - 1) / 2; k++) { for(int i = 1; i <= n; i++) { table[i][j] = 0; if(++placed == n / 2 + 1) { ans++; placed = 0; j++; } } } } void print() { if(!sw) { cout << ans << endl; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cout << (table[i][j] ? '+' : '-'); } cout << endl; } } else { cout << ans << endl; for(int j = 1; j <= m; j++) { for(int i = 1; i <= n; i++) { cout << (!table[i][j] ? '-' : '+'); } cout << endl; } } } int main() { // #ifdef ONLINE_JUDGE // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); // #endif ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; while(t--) { read(); solve(); print(); } 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...