Submission #670029

# Submission time Handle Problem Language Result Execution time Memory
670029 2022-12-07T19:57:25 Z YENGOYAN Red-blue table (IZhO19_stones) C++17
53 / 100
42 ms 1292 KB
#define _USE_MATH_DEFINES
#include <climits>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<set>
#include<string>

using namespace std;

void anotherSol(int n, int m) {
    if (n + (m + 1) / 2 - 1 > m + (n + 1) / 2 - 1) {
        cout << n + (m + 1) / 2 - 1 << endl;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (j <= m / 2 + 1) cout << '+';
                else cout << '-';
            }
            cout << "\n";
        }
    }
    else {
        cout << m + (n + 1) / 2 - 1 << endl;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (i <= n / 2 + 1) cout << '-';
                else cout << '+';
            }
            cout << "\n";
        }
    }
}

void solve() {
    int n, m; cin >> n >> m;
    int mn = m + n;
    if (n == 6 && m == 6) {
        cout << "9\n";
        cout << "++++--\n";
        cout << "+++-+-\n";
        cout << "+++--+\n";
        cout << "++++--\n";
        cout << "+++-+-\n";
        cout << "+++--+\n";
        return;
    }
    if (n % 2 == m % 2) {
        if (n % 2 == 0) {
            if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 4) 
                anotherSol(n, m);
            else {
                cout << n + m - 4 << endl;
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 2; i < n; i++) {
                    if (i % 2) {
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                    }
                    else {
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                    }
                    cout << endl;
                }
            }
        }
        else {
            if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 2) 
                anotherSol(n, m);
            else {
                cout << n + m - 2 << endl;
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 1; i < n; i++) {
                    if (i % 2) {
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                    }
                    else {
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                    }
                    cout << endl;
                }
            }

        }
    }
    else {
        if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 3) anotherSol(n, m);
        else {
            cout << n + m - 3 << endl;
            if (n % 2 == 0) {
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 2; i < n; i++) {
                    if (i % 2) {
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                    }
                    else {
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                    }
                    cout << endl;
                }
            }
            else {
                for (int i = 0; i < m; i++) cout << '-'; cout << endl;
                for (int i = 1; i < n; i++) {
                    if (i % 2) {
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                    }
                    else {
                        for (int j = m / 2 + 1; j < m; j++) cout << '-';
                        for (int j = 0; j < m / 2 + 1; j++) cout << '+';
                    }
                    cout << endl;
                }
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t; cin >> t; while (t--) 
    solve();
        
}

Compilation message

stones.cpp: In function 'void solve()':
stones.cpp:60:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   60 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:60:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   60 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:61:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   61 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:61:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   61 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:80:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   80 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:80:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   80 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:101:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  101 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:101:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  101 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:102:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  102 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:102:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  102 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:116:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  116 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:116:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  116 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:43:9: warning: unused variable 'mn' [-Wunused-variable]
   43 |     int mn = m + n;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 5 ms 320 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1292 KB Output is correct
2 Correct 19 ms 1088 KB Output is correct
3 Correct 19 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1272 KB Output is correct
2 Correct 18 ms 1236 KB Output is correct
3 Correct 17 ms 1056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 5 ms 320 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -