結果

問題 No.2112 All 2x2 are Equal
ユーザー milanis48663220milanis48663220
提出日時 2022-10-28 22:15:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 2,058 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 120,104 KB
実行使用メモリ 10,976 KB
最終ジャッジ日時 2023-09-20 05:16:54
合計ジャッジ時間 6,630 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 29 ms
6,188 KB
testcase_05 AC 36 ms
7,220 KB
testcase_06 AC 63 ms
10,332 KB
testcase_07 AC 21 ms
5,460 KB
testcase_08 AC 51 ms
9,020 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 24 ms
5,644 KB
testcase_11 AC 17 ms
4,872 KB
testcase_12 AC 20 ms
5,104 KB
testcase_13 AC 56 ms
9,628 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 41 ms
7,848 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 50 ms
8,748 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 48 ms
8,584 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 3 ms
4,384 KB
testcase_24 AC 8 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 13 ms
4,492 KB
testcase_28 AC 31 ms
6,428 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 20 ms
5,396 KB
testcase_31 AC 39 ms
7,588 KB
testcase_32 AC 67 ms
10,956 KB
testcase_33 AC 66 ms
10,868 KB
testcase_34 AC 67 ms
10,976 KB
testcase_35 AC 67 ms
10,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int h, w; cin >> h >> w;
    auto a = vec2d(h, w, 0);
    auto b = vec2d(h, w, 0);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i%2 == 0) a[i][j] = j;
            else a[i][j] = w-1-j;

            if(j%2 == 0) b[i][j] = i;
            else b[i][j] = h-1-i;
        }
    }
    if(h%2 == 0 && w%2 == 0){
        for(int i = 0; i < h; i+=2){
            for(int j = 0; j < w; j+=2){
                swap(a[i][j], a[i+1][j]);
            }
        }
    }
    // set<int> st;
    cout << "Yes" << endl;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int x = b[i][j]*w+a[i][j]+1;
            cout << x << ' ';
            // st.insert(x);
        }
        cout << endl;
    }
    // debug_value(st.size())
}
0