結果

問題 No.1434 Make Maze
ユーザー tanimani364tanimani364
提出日時 2021-04-07 01:31:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,696 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 204,008 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 22:06:32
合計ジャッジ時間 9,471 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 13 ms
4,368 KB
testcase_03 AC 13 ms
4,368 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 4 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 3 ms
4,368 KB
testcase_19 AC 8 ms
4,372 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 1 ms
4,368 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 AC 5 ms
4,368 KB
testcase_25 AC 9 ms
4,372 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 5 ms
4,372 KB
testcase_28 AC 2 ms
4,368 KB
testcase_29 AC 1 ms
4,368 KB
testcase_30 AC 3 ms
4,368 KB
testcase_31 AC 3 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;
void ng(){
  cout<<-1<<"\n";
  exit(0);
}
void print(const vector<vector<char>> &a){
  rep(i,a.size()){
    rep(j,a[i].size()){
      cout<<a[i][j];
    }
    cout<<"\n";
  }
}
void solve()
{	
 int h,w,x;
 cin>>h>>w>>x;
 int val=x-(h-1+w-1);
 if(val<0)ng();
 vector<vector<char>>ans(h,vector<char>(w,'.'));
 if(h%4==3&&w%4==3){
   for(int i=1;i<w;i+=2){
     rep(j,h-1){
       ans[j][i]='#';
     }
   }
   for(int j=3;j<w;j+=4){
     int maxv=0;
     int pos=h-1;
     for(int i=h-3;i>=0;i-=2){
       if(val>=abs(h-1-i)*2){
         if(chmax(maxv,abs(h-1-i)*2)){
           pos=i;
         }
       }
     }
     if(maxv>0){
      ans[pos][j]='.';
      ans[h-1][j]='#';
      val-=maxv;
    }
   }
   if(val>0){
     ans[0][w-2]='.';
     ans[1][w-3]='#';
     ans[h-1][w-2]='#';
     for(int i=2;i+2<h;i+=4){
       if(val>=4){
         ans[i][w-2]='.';
         ans[i+2][w-2]='.';
         ans[i+1][w-1]='#';
         if(i+3<h-2)ans[i+3][w-3]='#';
         val-=4;
       }
     }
   }
   if(val>0){
     ng();
   }else{
     print(ans);
   }
 }else if(h%4==3){
   for(int i=1;i<w;i+=2){
     rep(j,h-1){
       ans[j][i]='#';
     }
   }

   for(int j=3;j<w;j+=4){
     int maxv=0;
     int pos=h-1;
     for(int i=h-3;i>=0;i-=2){
       if(val>=abs(h-1-i)*2){
         if(chmax(maxv,abs(h-1-i)*2)){
           pos=i;
         }
       }
     }
     if(maxv>0){
      ans[pos][j]='.';
      ans[h-1][j]='#';
      val-=maxv;
    }
   }
   if(val>0){
     ng();
   }else{
     print(ans);
   }
 }else{
   for(int i=1;i<h;i+=2){
     rep(j,w-1){
       ans[i][j]='#';
     }
   }
   for(int i=3;i<h;i+=4){
      int maxv=0;
      int pos=w-1;
      for(int i=w-3;i>=0;i-=2){
        if(val>=abs(w-1-i)*2){
          if(chmax(maxv,abs(w-1-i)*2)){
            pos=i;
          }
        }
      }
      if(maxv>0){
        ans[i][pos]='.';
        ans[i].back()='#';
        val-=maxv;
      }
    }
    if(val>0)ng();
    else print(ans);
  }
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0