結果

問題 No.883 ぬりえ
ユーザー tonegawatonegawa
提出日時 2020-08-12 13:08:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,585 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 120,660 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-18 00:23:48
合計ジャッジ時間 1,881 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
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 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 32 ms
11,008 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  // ###
  // ###
  // ###
  ll m = (n/(k*k)) * k;
  ll ad = (n%(k*k));
  ll x = 0;
  for(int i=0;i<=k;i++){
    if(i*i>=ad){
      x = i;
      break;
    }
  }

  if((k+1)*k>=n&&m+x>=k+1){
    ll ad = n;
    std::cout << k+1 << '\n';
    for(int i=0;i<=k;i++){
      for(int j=0;j<=k;j++){
        if(i==j) std::cout << ".";
        else if(ad){
          std::cout << "#";
          ad--;
        }else std::cout << ".";
      }
      std::cout << '\n';
    }
    return 0;
  }
  std::cout << m + x << '\n';
  vvl d = VV(m+x, m+x, 0, ll);
  for(int i=0;i<m/k;i++){
    ll st = k*i;
    for(int j=0;j<k;j++){
      for(int l=0;l<k;l++){
        d[st+j][st+l] = 1;
      }
    }
  }

  ll st = k*(m/k);
  for(int i=0;i<x;i++){
    for(int j=0;j<x;j++){
      if(ad){
        d[st+i][st+j] = 1;
        ad--;
      }
    }
  }



  re(i, m+x){
    re(j, m+x){
      std::cout << (d[i][j]?'#':'.') << (j==m+x-1?"\n":"");
    }
  }
  return 0;
}
0