結果
問題 | No.197 手品 |
ユーザー |
![]() |
提出日時 | 2015-10-29 15:28:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,296 bytes |
コンパイル時間 | 661 ms |
コンパイル使用メモリ | 83,304 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 13:09:17 |
合計ジャッジ時間 | 1,842 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 WA * 2 |
ソースコード
#include <iostream> #include <cmath> #include <climits> #include <string> #include <vector> #include <queue> #include <stack> #include <functional> #include <algorithm> #include <sstream> #include <map> #include <set> #include <utility> #include <cstdio> #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define SZ(a) int((a).size()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define DEBUG(x) cout<<#x<<": "<<x<<endl using namespace std; typedef pair<int,int> P; typedef long long int LL; typedef pair<LL,LL> LP; int N; string sb,sa; bool dfs(int k,string s); int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>sa>>N>>sb; if(N>15){ int nax=0; int nbx=0; REP(i,3){ if(sa[i]=='x') nax++; if(sb[i]=='x') nbx++; } if(nax==nbx){ cout<<"FAILURE"<<endl; }else{ cout<<"SUCCESS"<<endl; } }else{ if(dfs(0,sb)){ cout<<"FAILURE"<<endl; }else{ cout<<"SUCCESS"<<endl; } } return 0; } bool dfs(int k,string s) { if(s==sa) return true; if(k==N){ return false; }else{ string s1=s.substr(0,1)+s.substr(2,1)+s.substr(1,1); string s2=s.substr(1,1)+s.substr(0,1)+s.substr(2,1); return dfs(k+1,s1)||dfs(k+1,s2); } }