結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー oliverx3oliverx3
提出日時 2021-02-19 21:40:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,111 bytes
コンパイル時間 2,717 ms
コンパイル使用メモリ 212,516 KB
実行使用メモリ 6,220 KB
最終ジャッジ日時 2023-10-15 00:25:46
合計ジャッジ時間 29,004 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 22 ms
6,040 KB
testcase_07 WA -
testcase_08 AC 23 ms
5,880 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 22 ms
6,068 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 22 ms
5,916 KB
testcase_17 AC 22 ms
5,924 KB
testcase_18 AC 22 ms
5,968 KB
testcase_19 AC 23 ms
5,916 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// using namespace std;
// #if __has_include(<atcoder/all>)
// #include<atcoder/all>
// // using namespace atcoder;
// #endif
#define int long long

#pragma region header

#pragma region alias

using lint = long long;
using ll = long long;
using P = std::pair<int,int>;
template<class T> using prique = std::priority_queue<T,std::vector<T>,std::greater<T>>;

#pragma endregion

#pragma region macros

#define rep(i, n) for(int i = 0;i<(int)(n);i++)
#define REP(i, m, n) for(int i = (m);i<(int)(n);i++)
#define drep(i, n) for(int i = (n)-1;i>=0;i--)
#define DREP(i, m, n) for(int i = (m)-1;i>=(int)(n);i--)
#define all(v) (v).begin(),(v).end()
#define reall(v) (v).rbegin(),(v).rend()

template<class T, class U>
bool chmax(T& a,const U b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T, class U>
bool chmin(T& a,const U b) {
    if(a>b) {
        a = b;
        return true;
    }
    return false;
}

std::map<int,int> prime_div(int n) {
    std::map<int,int> mp;
    if(~n&1) while(~n&1) n>>=1,mp[2]++;
    for(int i = 3;i<=std::sqrt(n);i+=2) {
        if(n%i==0) {
            while(n%i==0) {
                n/=i;
                mp[i]++;
            }
        }
    }
    if(n!=1) mp[n]++;
    return mp;
}

#pragma endregion

#pragma region constant

constexpr long long inf = 1LL << 61;
constexpr int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
constexpr long long mod = 1e9+7;
constexpr long long MOD = 998244353;

#pragma endregion

#pragma region inout

template<class T>
std::ostream& operator<<(std::ostream& stream, const std::vector<T>& v) {
    for(int i = 0; i < (int)(v.size()); i++) {
        stream << v[i];
        if(i != (int)(v.size()) - 1) stream << ' ';
    }
    return stream;
}

template<typename Itr>
inline void print(const Itr& begin, const Itr& end, bool endline = true, const char* BEGIN = "{", const char* mid = ", ", const char* END = "}") {
    if(begin == end) return;
    std::cout << BEGIN << *begin;
    for(Itr itr = begin+1; itr < end; itr++) std::cout << mid << *itr;
    std::cout << END;
    if(endline) std::endl(std::cout);
    return;
}

template<class T>
std::istream& operator>>(std::istream& stream, std::vector<T>& v) {
    for(T& p:v) stream >> p;
    return stream;
}

template<typename Itr>
inline void input(Itr begin, Itr end) {
    for(Itr& itr = begin; itr < end; itr++) std::cin >> *itr;
    return;
}

template<class T, class U>
std::ostream& operator<<(std::ostream& stream, const std::pair<T,U>& pair) {
    return stream << pair.first << ' ' << pair.second;
}

template<class T, class U>
inline void print(const std::pair<T,U>& pair,const bool endline = true, const char* begin = "(", const char* mid = ", ", const char* end = ")") {
    std::cout << begin << pair.first << mid << pair.second << end;
    if(endline) std::endl(std::cout);
    else std::cout << ' ';
    return;
}

template<class T, class U>
std::istream& operator>>(std::istream& stream, std::pair<T,U>& pair) {
    return stream >> pair.first >> pair.second;
}

template<class T, class U>
inline void input(std::pair<T,U>& pair, const bool first = true, const bool second = true) {
    if(first) std::cin >> pair.first;
    if(second) std::cin >> pair.second;
}

#pragma endregion

#pragma region DEBUG

#ifdef _DEBUG
#define debug(x) do{std::cout << #x << ": ";view(x);}while(0);
#else
#define debug(x)
#endif

template<class T> inline void view(const T& x) {
    std::cout << x << std::endl;
}

template<class T> inline void view(const std::vector<T>& v) {
    print(all(v));
}

#pragma endregion

#pragma endregion

signed main() {
    int w,h,x;
    std::cin >> w >> h >> x;
    if(x==0) {
        rep(i, h) {
            rep(j, w) std::cout << 0;std::endl(std::cout);
        }
        return 0;
    }
    if(h==1&&w==1) return !printf(x>9?"-1\n":"%lld\n",x);
    if(h==1) {
        if(x>18) return !printf("-1\n");
        std::vector<int> v(w,0);
        for(int i = 0;i<w;i+=3) v[i] = x/9*9;
        for(int i = 1;i<w;i+=3) v[i] = x%9;
        for(const auto &p:v) std::cout << p;
        std::endl(std::cout);
        return 0;
    }
    if(w==1) {
        if(x>18) return !printf("-1\n");
        std::vector<int> v(h,0);
        for(int i = 0;i<h;i+=3) v[i] = x/9*9;
        for(int i = 1;i<h;i+=3) v[i] = x%9;
        for(const auto &p:v) std::cout << p << std::endl;
        return 0;
    }
    if(x>36) return !printf("-1\n");
    std::vector<std::vector<int>> v(h, std::vector<int> (w,0));
    for(int i = 0;i<h;i+=3) {
        for(int j = 0;j<w;j+=3) {
            v[i][j] = (x-1)%9+1;
        }
    }
    for(int i = 1;i<h;i+=3) {
        for(int j = 0;j<w;j+=3) {
            v[i][j] = (x>=27)*9;
        }
    }
    for(int i = 0;i<h;i+=3) {
        for(int j = 1;j<w;j+=3) {
            v[i][j] = (x>=18)*9;
        }
    }
    for(int i = 1;i<h;i+=3) {
        for(int j = 1;j<w;j+=3) {
            v[i][j] = (x>=9)*9;
        }
    }
    rep(i, h) {
        rep(j, w) std::cout << v[i][j];std::endl(std::cout);
    }
    return 0;
}
0