結果
| 問題 |
No.1398 調和の魔法陣 (構築)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-19 21:40:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 5,111 bytes |
| コンパイル時間 | 2,083 ms |
| コンパイル使用メモリ | 209,240 KB |
| 最終ジャッジ日時 | 2025-01-18 23:28:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 17 |
ソースコード
#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;
}