Submission #54356346


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace atcoder;
namespace mp = boost::multiprecision;

using ll = long long;
using pll = pair<ll,ll>;
using T = tuple<ll, ll, ll>;
using bint = mp::cpp_int;

vector<string> rec(const ll K)
{
  vector<string> ret;
  ll K3 = 1;
  for(ll i = 0;i < K;i++)
  {
    K3 *= 3;
  }

  ret.resize(K3);

  if(K==0)
  {
    ret[0] = "#";
    return ret;
  }

  vector<string> JB = rec(K-1);
  ll J3 = K3/3;
  string white;
  for(ll i = 0;i < J3;i++)
  {
    white += ".";
  }
  for(ll i = 0; i < K3; i++)
  {
    ll j = i%J3;
    if(J3 <= i && i < J3*2 )
    {
      ret[i] = JB[j] + white + JB[j];
    }
    else
    {
      ret[i] = JB[j] + JB[j] + JB[j];
    }
  }
  
  return ret;
}

int main()
{
  ll N;
  cin >> N;

  vector<string> ans = rec(N);
  
  ll len = ans.size();
  for(ll i = 0; i < len; i++)
  {
    cout << ans[i] << endl;
  }

  return 0;
}

Submission Info

Submission Time
Task C - Sierpinski carpet
User n0dasalt
Language C++ 20 (gcc 12.2)
Score 250
Code Size 1037 Byte
Status AC
Exec Time 3 ms
Memory 4016 KiB

Compile Error

In file included from /usr/include/c++/12/ios:40,
                 from /usr/include/c++/12/istream:38,
                 from /usr/include/c++/12/sstream:38,
                 from /usr/include/c++/12/complex:45,
                 from /usr/include/c++/12/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:54,
                 from Main.cpp:1:
In static member function ‘static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)’,
    inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:423:21,
    inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:418:7,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.tcc:532:22,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::assign(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:1647:19,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:815:28,
    inlined from ‘std::vector<std::__cxx11::basic_string<char> > rec(ll)’ at Main.cpp:27:14:
/usr/include/c++/12/bits/char_traits.h:431:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets -4611686018427387902 and [-4611686018427387903, 4611686018427387904] may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 9
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3596 KiB
example_01.txt AC 1 ms 3544 KiB
test_00.txt AC 1 ms 3800 KiB
test_01.txt AC 1 ms 3728 KiB
test_02.txt AC 1 ms 3528 KiB
test_03.txt AC 1 ms 3732 KiB
test_04.txt AC 1 ms 3564 KiB
test_05.txt AC 3 ms 4016 KiB
test_06.txt AC 1 ms 3536 KiB