結果

問題 No.883 ぬりえ
ユーザー alexara1123alexara1123
提出日時 2019-09-13 23:16:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,432 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 84,388 KB
実行使用メモリ 35,516 KB
最終ジャッジ日時 2023-09-17 15:19:38
合計ジャッジ時間 2,623 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
35,380 KB
testcase_01 AC 15 ms
35,220 KB
testcase_02 AC 15 ms
35,208 KB
testcase_03 AC 14 ms
35,252 KB
testcase_04 AC 15 ms
35,216 KB
testcase_05 AC 14 ms
35,364 KB
testcase_06 AC 14 ms
35,204 KB
testcase_07 WA -
testcase_08 AC 14 ms
35,212 KB
testcase_09 WA -
testcase_10 AC 14 ms
35,340 KB
testcase_11 AC 14 ms
35,216 KB
testcase_12 AC 14 ms
35,208 KB
testcase_13 AC 14 ms
35,212 KB
testcase_14 AC 14 ms
35,200 KB
testcase_15 AC 51 ms
35,256 KB
testcase_16 AC 24 ms
35,364 KB
testcase_17 AC 19 ms
35,204 KB
testcase_18 AC 14 ms
35,252 KB
testcase_19 AC 14 ms
35,316 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;
typedef pair<int, int> P;
string grid[1010][1010];

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);

   int n, k;
   cin >> n >> k;

   if (n <= k * k)
   {
      ll ans = 1, t = 1;
      for (int i = 1; i < k + 1; i++)
      {
         if (i * i >= n)
         {
            ans = i;
            break;
         }
      }

      cout << ans << endl;
      ll cnt = 0;
      for (int i = 0; i < ans; i++)
      {
         for (int j = 0; j < ans; j++)
         {
            if (cnt < n)
            {
               cout << "#";
            }
            else
            {
               cout << ".";
            }
            cnt++;
         }
         cout << endl;
      }
   }
   else
   {
      int t = k * k, ans = k;
      while (true)
      {
         if (n - t <= k * k)
         {
            break;
         }
         ans += k;
         t += k * k;
      }
      int x = 1;
      while (true)
      {
         if ((n - t) <= x * x)
         {
            ans += x;
            break;
         }
         x += 1;
      }

      cout << ans << endl;
      for (int i = 0; i < ans; i++)
      {
         for (int j = 0; j < ans; j++)
         {
            grid[i][j] = ".";
         }
      }

      ll cnt = 0;
      for (int i = 0; i < ans; i = i + k)
      {
         if (ans - i < k)
         {
            for (int a = i; a < x + i; a++)
            {
               for (int b = i; b < x + i; b++)
               {
                  if (cnt < n)
                  {
                     grid[a][b] = "#";
                  }
                  cnt++;
               }
            }
         }
         else
         {
            for (int a = i; a < k + i; a++)
            {
               for (int b = i; b < k + i; b++)
               {
                  if (cnt < n)
                  {
                     grid[a][b] = "#";
                  }
                  cnt++;
               }
            }
         }
      }

      for (int i = 0; i < ans; i++)
      {
         for (int j = 0; j < ans; j++)
         {
            cout << grid[i][j];
         }
         cout << endl;
      }
   }
}
0