1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Paiza】Bクラス問題をCopilotに解かせて虚無る

Last updated at Posted at 2025-02-06

帰ってきたぜっ!!

2025年のこの1年が自分の残り寿命だと思って生きると決めた者です。

なんとなく危機感からPaiza再開

昨日より少し強くなるためにPaizaを開きました。
そうしましたら、なんとも愉快そうなコンテンツがあ〜りませんか。
まんまと着手。

問題はこちらの「ギャングのアジト」(ピクセルアートの対称性検査プログラム)

よくわからないのでとりあえずCopilotさんに問題文を投げて、ご回答をいただく。

ミッションクリア

PythonとC++でコードを作成してもらい、無事に正解。さすがCopilotさん。

 (((((((((((゚▽゚))))))))))))

さあ、ここから私はどうしたら強くなれるのでしょうか。。。

とりあえず、皆様のBランクのWrite up記事でも眺めていこうかなと思います。

せっかくなのでコードを置いておく

Python
def is_symmetric(pixel_art): 
    N = len(pixel_art)
    for i in range(N):
        for j in range(N // 2):
            if pixel_art[i][j] != pixel_art[i][N - j - 1]:
                return False
    return True

#入力例
N = int(input().strip())
pixel_art = []
for _ in range(N):
    row = list(map(int, input().strip().split()))
    pixel_art.append(row)

#判定
if is_symmetric(pixel_art):
    print("Yes")
else:
    print("No")
C++
#include <iostream>
#include <vector>
using namespace std;

bool is_symmetric(const vector<vector<int>>& pixel_art) {
    int N = pixel_art.size();
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N / 2; ++j) {
            if (pixel_art[i][j] != pixel_art[i][N - j - 1]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> pixel_art(N, vector<int>(N));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> pixel_art[i][j];
        }
    }

    if (is_symmetric(pixel_art)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

感動

(実際に他の方の記事を読んで追記)

どうやらこの手の問題は、自分で関数を作って利用するみたいだ!←
関数を構築する為に、アルゴリズムの知識が必要という訳ですね。

楽しくなってきたあ

参考記事

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?