結果
| 問題 |
No.1156 Nada Picnic 2
|
| ユーザー |
a01sa01to
|
| 提出日時 | 2024-10-09 00:33:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 1,640 bytes |
| コンパイル時間 | 3,101 ms |
| コンパイル使用メモリ | 246,924 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 00:33:46 |
| 合計ジャッジ時間 | 3,707 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
int n;
cin >> n;
vector<int> p(10);
iota(p.begin(), p.end(), 0);
do {
if (n == 1) {
// 0:シ, 1:イ, 2:タ, 3:ケ, 4:ヤ, 5:マ, 6:キ
int shiita = p[0] * 100 + p[1] * 10 + p[2];
int keyama = p[3] * 100 + p[4] * 10 + p[5];
int ikitai = p[1] * 1000 + p[6] * 100 + p[2] * 10 + p[1];
if (shiita + keyama == ikitai && p[1] != 0) {
cout << ikitai << endl;
return 0;
}
}
else if (n == 2) {
// 0:オ, 1:ツ, 2:カ, 3:コ, 4:ク, 5:サ, 6:イ, 7:ビ, 8:ジ, 9:ン
int ootsuka = p[0] * 1000 + p[0] * 100 + p[1] * 10 + p[2];
int kokusai = p[3] * 1000 + p[4] * 100 + p[5] * 10 + p[6];
int bijitsukan = p[7] * 10000 + p[8] * 1000 + p[1] * 100 + p[2] * 10 + p[9];
if (ootsuka + kokusai == bijitsukan && p[7] != 0) {
cout << bijitsukan << endl;
return 0;
}
}
else {
// 0:s, 1:p, 2:r, 3:i, 4:n, 5:g, 6:e, 7:h, 8:t, 9:c
int spring = p[0] * 100000 + p[1] * 10000 + p[2] * 1000 + p[3] * 100 + p[4] * 10 + p[5];
int eight = p[6] * 10000 + p[3] * 1000 + p[5] * 100 + p[7] * 10 + p[8];
int picnic = p[1] * 100000 + p[3] * 10000 + p[9] * 1000 + p[4] * 100 + p[3] * 10 + p[9];
if (spring + eight == picnic && p[1] != 0) {
cout << picnic << endl;
return 0;
}
}
} while (next_permutation(p.begin(), p.end()));
return 0;
}
a01sa01to