p361.ans1
======================
#00
0#0
00#

=================
p361.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n, m;

void read() { cin >> n >> m; }

void solve() {
    // Try all 3 possible diagonal patterns (offset 0, 1, 2)
    // Each pattern creates diagonal lines with period 3
    int min_count = INT_MAX;
    int best_offset = 0;

    // Test each of the 3 possible diagonal offsets
    for(int offset = 0; offset < 3; offset++) {
        int count = 0;

        // Count how many '#' symbols this offset would create
        for(int i = 0; i < n; i++) {
            // For row i, place '#' at columns: (i + offset) % 3, (i + offset) %
            // 3 + 3, (i + offset) % 3 + 6, ... This creates a diagonal pattern
            // with period 3
            for(int j = (i + offset) % 3; j < m; j += 3) {
                count++;
            }
        }

        // Keep track of the offset that minimizes the number of '#' symbols
        if(count < min_count) {
            min_count = count;
            best_offset = offset;
        }
    }

    // Create the grid using the best offset pattern
    // Use vector of strings for cleaner memory management
    vector<string> grid(n, string(m, '0'));

    // Fill the grid with '#' symbols using the optimal diagonal pattern
    for(int i = 0; i < n; i++) {
        // Place '#' at positions following the diagonal pattern
        for(int j = (i + best_offset) % 3; j < m; j += 3) {
            grid[i][j] = '#';
        }
    }

    // Output the resulting grid
    for(int i = 0; i < n; i++) {
        cout << grid[i] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p361.in1
======================
3 3 

=================
statement.txt
======================
361. National Flag
Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



Series of bloody civil wars in Berland finished! After the long-awaited reunion it was decided to create new Berland flag. Berland Heraldic Council proposed following requirements:

1. Berland flag must be a rectangle of Nx M cells. Each cell must be painted with blue or red;

2. any 3x 2 or 2x 3 rectangle of the flag must have exactly two blue cells;

3. blue paint is very expensive, so the number of blue cells should as low as possible.

Write a program that creates Berland flag.

Input
Input file contains two integer numbers N and M (3 ≤ N, M ≤ 200) separated by a space.

Output
Print to the output file N lines with M characters on each line: j-th character on the i-th line must be 0 (zero) if the cell (i, j) painted with read, and "#" if it is blue. If there are several solutions output any of them. Print "No solution" (without quotes) if there is no solution.

Example(s)
sample input
sample output
3 3
#00 
00# 
0#0

=================
