結果

問題 No.725 木は明らかに森である
ユーザー hiyorihiyori
提出日時 2019-02-08 18:10:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 65,516 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 22:56:46
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdlib.h>
#include<string>

using namespace std;

void run();
void change_forest(string s, string sub_str);

int main()
{
    run();
    return EXIT_SUCCESS;
}

void run()
{
    string s,sub_str="treeone";;
    cin>>s;
    if(s.length()<sub_str.length()){
        cout<<s<<endl;
    }
    else{
        change_forest(s,sub_str);
    }
}

void change_forest(string s, string sub_str)
{
    int sub_length = sub_str.length();
    for(int i=0;i<s.length();i++){
        for(int j=0;j<sub_length;j++){
            if(s[i+j]!=sub_str[j]){break;}
            else if(j==sub_length-1&&s[i+j]==sub_str[j]){
                s.replace(i,i+sub_length,"forest");
            }
        }
    }
    cout<<s<<endl;
}

0