Untitled

mail@pastecode.io avatar
unknown
plain_text
6 days ago
2.6 kB
3
Indexable
Never
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db double
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define speed ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
/*
                    " وَأَن لَّيْسَ لِلْإِنسَانِ إِلَّا مَا سَعَى ﴿39﴾ وَأَنَّ سَعْيَهُ سَوْفَ يُرَى ﴿40﴾ ثُمَّ يُجْزَاهُ الْجَزَاء الْأَوْفَى "
*/
const ll N = 5e5 + 5, inf = 2e18, mod = 1e9 + 7;
ll dx[] = {0, 0, -1, 1, -1, 1, 1, -1};
ll dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
char di[] = {'R', 'L', 'U', 'D'};

void print_num(ll n) {
    if (n <= 1) {
        cout << n;
        return;
    }
    print_num(n >> 1);
    cout << (n & 1);
}


int ans[210][210];

void solve() {
//    print_num(7);
//    cout << "\n";
//    print_num(10);
//    cout << "\n";
//    print_num(417);
//    cout << "\n";
//    print_num(420);
//    cout << "\n\n";
//    print_num(11);
//    cout << "\n";
//    print_num(421);
//    cout << "\n";
//    print_num(14);
//    cout << "\n";
//    print_num(424);
//    cout << "\n";

    cout<<"----------------------\n";
    ll n, m;
    cin >> n >> m;
    cout << n * m << "\n";
    for (int i = 0; i < (n+3)/4; ++i) {
        for (int j = 0; j < (m+3)/4; ++j) {
            ll x=0;
            for (int k = i; k <i+4 ; ++k) {
                for (int l = j; l < j + 4; ++l) {
                    cout<<ans[k][l]<<" ";
                    x^=ans[k][l];
                }
                cout<<"\n";
            }
            cout<<x<<" ----------------------\n";
        }
    }
}

void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    speed
    file();
    int testcases = 1;
    ll val = 4;
    for (int j = 0; j < 205; j += 2) {
        for (int k = 0; k < 205; k += 2) {
            ans[j][k] = val;
            ans[j][k + 1] = val + 1;
            ans[j + 1][k] = val + 2;
            ans[j + 1][k + 1] = val + 3;
            val += 4;
        }
    }
    cin >> testcases;
    while (testcases--)
        solve();
}

Leave a Comment