結果

問題 No.1434 Make Maze
ユーザー CleyLCleyL
提出日時 2021-03-19 23:36:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,207 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 98,452 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-29 19:31:49
合計ジャッジ時間 6,236 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん!
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん!
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう!
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん!
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく!
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー!
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー!!
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/


__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int h,w,x;cin>>h>>w>>x;
  char a[h][w];
  for(int i = 0; h > i; i++){
    for(int j = 0; w > j; j++){
      int I = i+1,J = j+1;
      if((I%2) && (J%2)){
        a[i][j] = '.';
      }else if((!(I%2)) && (!(J%2))){
        a[i][j] = '#';
      }else{
        a[i][j] = '.';
      }
    }
  }
  //必要数
  int wan = ((h-1)/2)*((w-1)/2);
  //最大値 
  int nun = h*(w/2+1)+w/2;
  if((x-(h+w-1)+1)%4 || x<(h+w-1)-1 || x>nun){
    cout << -1 << endl;
  }else{
    //3,7,11...は偶数列なので(頭が)バグるため、奇数列を元に考えるのが得策
    if((!((h+1)%4)) && (!((w+1)%4)) ){
      //偶数列しかない場合
      for(int i = 3; w > i; i+=4){
        for(int j = 2; h > j; j+=2){
          a[j][i] = '#';
        }
      }
      int mv = (x-(h+w-1)+1)/4;
      int i = 1;
      for(; w-2 > i; i+=4){
        if(h/2 <= mv){
          for(int j = 0; h-2 > j; j+=2){
            a[j][i] = '#';
            mv--;
          }
        }else if(mv){
          int j = 0;
          for(;h > j && mv;j+=2){
            a[j][i] = '#';
            mv--;
          }
          j+=2;
          for(;w > j; j+=2){
            a[j][i] = '#';
          }
        }else{
          for(int j = 2; h > j; j+=2){
            a[j][i] = '#';
          }
        }
      }
      if(mv){
        cout << "nyan" << endl;
        //3*hの形にする
        for(int I = 1; h > I; I+=4){
          a[I][w-3] = '#';
        }
        for(int I = 3; h > I; I+=4){
          if(mv){
            a[I][w-1] = '#';
          }
        }
      }else{
        if(h/2 <= mv){
          for(int j = 0; h-2 > j; j+=2){
            a[j][i] = '#';
            mv--;
          }
        }else if(mv){
          int j = 0;
          for(;h > j && mv;j+=2){
            a[j][i] = '#';
            mv--;
          }
          j+=2;
          for(;w > j; j+=2){
            a[j][i] = '#';
          }
        }else{
          for(int j = 2; h > j; j+=2){
            a[j][i] = '#';
          }
        }
      }
    }else if((h+1)%4){
      int mv = (x-(h+w-1)+1)/4;
      for(int i = 1; h > i; i+=4){
        if(w/2 <= mv){
          //全部左側
          for(int j = 0; w-2 > j; j+=2){
            a[i][j] = '#';
            mv--;
          }
        }else if(mv){
          //mv個左側
          int j = 0;
          for(;w > j && mv; j+=2){
            a[i][j] = '#';
            mv--;
          }
          j+=2;
          for(;w > j; j+=2){
            a[i][j] = '#';
          }
        }else{
          //全部左側
          for(int j = 2; w > j; j+=2){
            a[i][j] = '#';
          }
        }
      }
      for(int i = 3; h > i; i+=4){
        for(int j = 2; w > j; j+=2){
          a[i][j] = '#';
        }
      }
    }else{
      int mv = (x-(h+w-1)+1)/4;
      for(int i = 1; w > i; i+=4){
        if(h/2 <= mv){
          for(int j = 0; h-2 > j; j+=2){
            a[j][i] = '#';
            mv--;
          }
        }else if(mv){
          int j = 0;
          for(;h > j && mv;j+=2){
            a[j][i] = '#';
            mv--;
          }
          j+=2;
          for(;w > j; j+=2){
            a[j][i] = '#';
          }
        }else{
          for(int j = 2; h > j; j+=2){
            a[j][i] = '#';
          }
        }
      }
      
      for(int i = 3; w > i; i+=4){
        for(int j = 2; h > j; j+=2){
          a[j][i] = '#';
        }
      }
    }
    for(int i = 0; h > i; i++){
      for(int j = 0; w > j; j++){
        cout << a[i][j];
      }
      cout << endl;
    }
  }


}
0