Submission #498846

#TimeUsernameProblemLanguageResultExecution timeMemory
498846alimurodovRed-blue table (IZhO19_stones)C++14
27 / 100
37 ms1188 KiB
#include <bits/stdc++.h> using namespace std; void solve(){ int n, m; cin >> n >> m; if(n >= 3 && m >= 3){ if(n < m){ int s = m; char a[100][100]; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ a[i][j] = '-'; } } if(n % 2 && m % 2){ s += n / 2; for(int i = 0; i < n / 2; i++){ for(int j = 0; j < m / 2 + 1; j++){ a[i][j] = '+'; } } }else if(n % 2 && m % 2 == 0){ s += n / 2; for(int i = 0; i < n / 2; i++){ for(int j = 0; j < m / 2 + 1; j++){ a[i][j] = '+'; } } }else if(n % 2 == 0 && m % 2){ s += n / 2; for(int i = 0; i < n / 2; i++){ for(int j = 0; j < m / 2 + 1; j++){ a[i][j] = '+'; } } } else{ s += n / 2; for(int i = 0; i < n / 2; i++){ for(int j = 0; j < m / 2 + 1; j++){ a[i][j] = '+'; } } } cout << s << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << a[i][j]; } cout << '\n'; } } else{ int s = n; char a[100][100]; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ a[i][j] = '+'; } } if(n % 2 && m % 2){ s += m / 2; for(int i = 0; i < n / 2 + 1; i++){ for(int j = 0; j <= m / 2 - 1; j++){ a[i][j] = '-'; } } }else if(n % 2 && m % 2 == 0){ s += m / 2 - 1; for(int i = 0; i < n / 2 + 1; i++){ for(int j = 0; j < m / 2 - 1; j++){ a[i][j] = '-'; } } }else if(n % 2 == 0 && m % 2){ s += m / 2; for(int i = 0; i < n / 2 + 1; i++){ for(int j = 0; j < m / 2; j++){ a[i][j] = '-'; } } } else{ s += n / 2 - 1; for(int i = 0; i < n / 2 + 1; i++){ for(int j = 0; j < m / 2 - 1; j++){ a[i][j] = '-'; } } } cout << s << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << a[i][j]; } cout << '\n'; } } } else{ if(n < m){ cout << m << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << '-'; } cout << '\n'; } } else{ cout << n << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << '+'; } cout << '\n'; } } } } int main(){ 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...