結果
問題 | No.197 手品 |
ユーザー |
![]() |
提出日時 | 2018-08-01 18:33:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 2,307 bytes |
コンパイル時間 | 1,668 ms |
コンパイル使用メモリ | 172,068 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 03:54:48 |
合計ジャッジ時間 | 2,611 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h>using namespace std;using VS = vector<string>; using LL = long long;using VI = vector<int>; using VVI = vector<VI>;using PII = pair<int, int>; using PLL = pair<LL, LL>;using VL = vector<LL>; using VVL = vector<VL>;#define ALL(a) begin((a)),end((a))#define RALL(a) (a).rbegin(), (a).rend()#define SZ(a) int((a).size())#define SORT(c) sort(ALL((c)))#define RSORT(c) sort(RALL((c)))#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)#define debug(x) cerr << #x << ": " << x << endlconst int INF = 1e9; const LL LINF = 1e16;const LL MOD = 1000000007; const double PI = acos(-1.0);int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 }; int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };/* ----- 2018/07/31 Problem: yukicoder 197 / Link: http://yukicoder.me/problems/no/197 ----- *//* ------問題------A君は手品の練習をしている。手品は次のようなものである。コインが1つ入っているか入っていない帽子が3つ並んでいる。A君は最初にすべての帽子にコインが入っているかいないかを見せる。1回の操作によって左側の2つか右側の2つの帽子を中身ごと入れ替えることができる。A君はお客さんに頼んでちょうどN回だけ好きなように操作を行ってもらう。(このとき操作の回数は明らかだが、どのように行ったかは見えない。)A君がすべての帽子を開けたときにあり得ない状態になっていれば手品は成功である。A君の手品が成功していれば"SUCCESS"、失敗なら"FAILURE"と言ってあげましょう。-----問題ここまで----- *//* -----解説等---------解説ここまで---- */int main() {cin.tie(0);ios_base::sync_with_stdio(false);string a, b;LL N;cin >> a >> N >> b;int ok = 1;if (N < 2) {if (N == 0) {ok &= (a != b);}else if (N == 1) {FOR(i, 0, 2) {string t = a;swap(t[i], t[i + 1]);if (t == b)ok = 0;}}}else {SORT(a), SORT(b);ok &= (a != b);}cout << (ok ? "SUCCESS" : "FAILURE") << endl;return 0;}