提出 #54370211


ソースコード 拡げる

#include <bits/stdc++.h>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int sz = pow(3, n);
    int midstart = (int)pow(3, n) / 2 - (int)pow(3, n - 1) / 2;
    int midend = (int)pow(3, n) / 2 + (int)pow(3, n - 1) / 2;
    int smallgridsz = pow(3, n - 1);
    vector<vector<char>> ans(sz, vector<char>(sz, '#'));
    if (n == 1)
    {
        ans[1][1] = '.';
        for (int i = 0; i < sz; i++)
        {
            for (int j = 0; j < sz; j++)
            {
                cout << ans[i][j];
            }
            cout << endl;
        }
        return;
    }
    for (int i = 0; i < sz; i++)
    {
        for (int j = 0; j < sz; j++)
        {
            if (i == (int)pow(3, n) / 2)
            {
                if ((j == (int)pow(3, n) / 2 || j == (int)pow(3, n) / 2 - pow(3, n - 1) || j == (int)pow(3, n) / 2 + pow(3, n - 1)))
                    ans[i][j] = '.';
            }
            if (i == (int)pow(3, n) / 2 + (pow(3, n - 1)))
            {
                if ((j == (int)pow(3, n) / 2 || j == (int)pow(3, n) / 2 - pow(3, n - 1) || j == (int)pow(3, n) / 2 + pow(3, n - 1)))
                    ans[i][j] = '.';
            }
            if (i == (int)pow(3, n) / 2 - (pow(3, n - 1)))
            {
                if ((j == (int)pow(3, n) / 2 || j == (int)pow(3, n) / 2 - pow(3, n - 1) || j == (int)pow(3, n) / 2 + pow(3, n - 1)))
                    ans[i][j] = '.';
            }
            if (i >= midstart && i <= midend && j >= midstart && j <= midend)
            {

                ans[i][j] = '.';
            }
        }
    }
    for (int i = 0; i < sz; i++)
    {
        for (int j = 0; j < sz; j++)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}
int main()
{
    fastio;
    solve();
    return 0;
}

提出情報

提出日時
問題 C - Sierpinski carpet
ユーザ vanshcodes583
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1983 Byte
結果 WA
実行時間 47 ms
メモリ 3868 KiB

コンパイルエラー

Main.cpp: In function ‘void solve()’:
Main.cpp:18:9: warning: unused variable ‘smallgridsz’ [-Wunused-variable]
   18 |     int smallgridsz = pow(3, n - 1);
      |         ^~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 250
結果
AC × 2
AC × 4
WA × 5
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3600 KiB
example_01.txt AC 1 ms 3828 KiB
test_00.txt WA 6 ms 3768 KiB
test_01.txt AC 1 ms 3708 KiB
test_02.txt WA 1 ms 3608 KiB
test_03.txt WA 1 ms 3644 KiB
test_04.txt WA 1 ms 3688 KiB
test_05.txt WA 47 ms 3868 KiB
test_06.txt AC 1 ms 3656 KiB