結果

問題 No.1156 Nada Picnic 2
ユーザー ooooobaoooooba
提出日時 2021-06-20 16:02:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,363 bytes
コンパイル時間 1,170 ms
コンパイル使用メモリ 119,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 01:26:04
合計ジャッジ時間 1,632 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 25 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:44:21: 警告: ‘z’ may be used uninitialized [-Wmaybe-uninitialized]
   44 |             cout << z << endl;
      |                     ^
main.cpp:27:23: 備考: ‘z’ はここで定義されています
   27 |         int32_t x, y, z;
      |                       ^
main.cpp:43:15: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
   43 |         if (x + y == z) {
      |             ~~^~~
main.cpp:27:20: 備考: ‘y’ はここで定義されています
   27 |         int32_t x, y, z;
      |                    ^
main.cpp:43:15: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
   43 |         if (x + y == z) {
      |             ~~^~~
main.cpp:27:17: 備考: ‘x’ はここで定義されています
   27 |         int32_t x, y, z;
      |                 ^

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int32_t n;
    cin >> n;
    vector<int32_t> d(10);
    for (auto i = 0; i < 10; ++i) {
        d[i] = i;
    }
    do {
        int32_t x, y, z;
        if (n == 1) {
            x = d[0] * 100 + d[1] * 10 + d[2];
            y = d[3] * 100 + d[4] * 10 + d[5];
            z = d[1] * 1000 + d[6] * 100 + d[2] * 10 + d[1];
        } else if (n == 2) {
            x = d[0] * 1000 + d[0] * 100 + d[1] * 10 + d[2];
            y = d[3] * 1000 + d[4] * 100 + d[5] * 10 + d[6];
            z = d[7] * 10000 + d[8] * 1000 + d[1] * 100 + d[2] * 10 + d[9];
        } else if (n == 3) {
            x = d[0] * 100000 + d[1] * 10000 + d[2] * 1000 + d[3] * 100 +
                d[4] * 10 + d[5];
            y = d[6] * 10000 + d[3] * 1000 + d[5] * 100 + d[7] * 10 + d[8];
            z = d[1] * 100000 + d[3] * 10000 + d[9] * 1000 + d[4] * 100 +
                d[3] * 10 + d[9];
        }
        if (x + y == z) {
            cout << z << endl;
            return 0;
        }
    } while (next_permutation(d.begin(), d.end()));
    return 0;
}
0