結果

問題 No.197 手品
ユーザー odan3240odan3240
提出日時 2016-01-06 23:26:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,635 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 106,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 20:42:23
合計ジャッジ時間 2,870 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,380 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
4,376 KB
testcase_44 WA -
testcase_45 AC 1 ms
4,376 KB
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0