結果
| 問題 |
No.1156 Nada Picnic 2
|
| ユーザー |
|
| 提出日時 | 2021-06-20 16:02:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,363 bytes |
| コンパイル時間 | 1,796 ms |
| コンパイル使用メモリ | 114,876 KB |
| 最終ジャッジ日時 | 2025-01-22 10:30:59 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:15: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
43 | if (x + y == z) {
| ~~^~~
main.cpp:27:17: note: ‘x’ was declared here
27 | int32_t x, y, z;
| ^
main.cpp:43:15: warning: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
43 | if (x + y == z) {
| ~~^~~
main.cpp:27:20: note: ‘y’ was declared here
27 | int32_t x, y, z;
| ^
main.cpp:43:9: warning: ‘z’ may be used uninitialized [-Wmaybe-uninitialized]
43 | if (x + y == z) {
| ^~
main.cpp:27:23: note: ‘z’ was declared here
27 | int32_t x, y, z;
| ^
ソースコード
#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;
}