# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670042 | 2022-12-07T21:48:18 Z | Vahaghar | Red-blue table (IZhO19_stones) | C++17 | 52 ms | 1784 KB |
#define _USE_MATH_DEFINES #include<iostream> #include<vector> #include<cmath> #include<iomanip> #include<algorithm> #include<set> #include<string> using namespace std; using ll = long long; using ull = unsigned long long; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } ll binpow(ll a, ll b) { if (b == 0) return 1; ll res = binpow(a, b / 2); if (b % 2) return res * res * a; return res * res; } bool isprime(int n) { if (n == 1 || n == 0) return 0; for (int i = 2; i * i <= n; i++) if (!(n % i)) return 0; return 1; } void solve() { int n, m; cin >> n >> m; int mn = m + n; //if (n == m && n % 2) { // cout << mn - 2 << endl; //} //else if (n == m && !(n % 2)) { // cout << mn - 4 << endl; //} if (m <= 2 && m < n) { cout << n << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << '+'; } cout << endl; } return; } if (n <= 2) { cout << m << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << '-'; } cout << endl; } return; } if (n <= 4 && m <= 4) { cout << 5 << endl; } else if ((n % 2) != (m % 2)) cout << mn - 3 << endl; else { if (n % 2) cout << mn - 2 << endl; else cout << mn - 4 << endl; } vector<vector<char>> v(n * m); if (m > 4 || n > 4 || n == 3 && m == 3) { for (int j = 0; j < m; j++) v[0].push_back('-'); for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { if ((i % 2)){ if (j < (m / 2 + 1)) { v[i].push_back('+'); } else v[i].push_back('-'); } else { if (j >= (m - m / 2 - 1)) { v[i].push_back('+'); } else v[i].push_back('-'); } } } if (!(n % 2)) { for (int j = 0; j < m; j++) v[n - 1][j] = '-'; } } else if(n == m || (n == 3 && m == 4)) { for (int j = 0; j < m; j++) v[0].push_back('+'); for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { v[i].push_back('-'); } } } else if (n == 4 && m == 3) { for (int j = 0; j < m; j++) v[0].push_back('+'); for (int i = 1; i < 4; i++) { for (int j = 0; j < 2; j++) v[i].push_back('+'); v[i].push_back('-'); } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << v[i][j]; } cout << endl; } // // ++ // ++ // // ------ // ------ // // ---- // ---- // ++++ // // +++ // ++- // ++- // ++- // // // ++ // ++ // ++ // ++ // ++ // ++ // // ++-+-+ // +----+ // +-+-++ // // ++-+- // +---- // +-+-+ // // --- // ++- // -++ // ++- // -++ // // ----- // +++-- // --+++ // ----- // // ++- // ++- // ++- // +++ // // // // ----- // ----- // --+++ // +++-- // // ------- // ++++--- // ---++++ // ++++--- // ---++++ // ------- // // -------- // +++++--- // ---+++++ // +++++--- // ---+++++ // +++++--- // ---+++++ // // // // } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int t; cin >> t; while(t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 340 KB | Wrong answer in test 3 6: 6 < 7 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 52 ms | 1572 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 1784 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |