結果
| 問題 |
No.197 手品
|
| コンテスト | |
| ユーザー |
odan3240
|
| 提出日時 | 2016-01-06 23:26:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,635 bytes |
| コンパイル時間 | 974 ms |
| コンパイル使用メモリ | 103,096 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 13:14:15 |
| 合計ジャッジ時間 | 2,208 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 23 |
ソースコード
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
string S1,S2;
ll N;
int cnt(string s) {
int ret=0;
rep(i,s.size()) if(s[i]=='o') ret++;
return ret;
}
int bfs() {
queue<pair<string,int>> que;
que.push(mp(S1,0));
map<string, int> d;
d[S1]=0;
while(que.size()) {
auto state=que.front(); que.pop();
string tmp=state.first;
swap(tmp[0],tmp[1]);
if(d.count(tmp)==0) {
d[tmp]=d[state.first]+1;
que.push(mp(tmp,d[tmp]));
}
tmp=state.first;
swap(tmp[1],tmp[2]);
if(d.count(tmp)==0) {
d[tmp]=d[state.first]+1;
que.push(mp(tmp,d[tmp]));
}
}
return d[S2];
}
int main() {
cin>>S1>>N>>S2;
if(cnt(S1)!=cnt(S2)) {
cout<<"SUCCESS"<<endl;
return 0;
}
int d=bfs();
if(d>N) {
cout<<"SUCCESS"<<endl;
return 0;
}
if((N-d)%2==0) {
cout<<"FAILURE"<<endl;
}
else {
cout<<"SUCCESS"<<endl;
}
return 0;
}
odan3240