結果

問題 No.342 一番ワロタww
ユーザー dosuken123dosuken123
提出日時 2016-02-13 00:28:25
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,148 bytes
コンパイル時間 3,199 ms
コンパイル使用メモリ 96,312 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 03:47:05
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

string findw(size_t from, string input) {
    std::size_t found = 0;
    std::size_t tmp_found = 0;
    //    cout << "from-found+3 = " << (from-found+3) << " from = " << from << endl;
    while ((found = input.find("w",found))!=std::string::npos && (found<from)) {
        //        cout << "found = " << found << " from = " << from << endl;
        found += 3;
        tmp_found = found;
    }
    //    cout << "tmp_found = " << tmp_found << endl;
    //    if (found ==std::string::npos) found = 0;
//    if (tmp_found == 0) tmp_found -= 3;
    return input.substr(tmp_found,from-tmp_found+3);
}

int main(int argc, const char * argv[])
{
    string input;
    cin >> input;
    std::size_t found = 0;
    std::size_t tmp_found = 0;
    int count = 0;
    int max_count = 0;
    vector<string> ret;
    while ((found = input.find("w",found))!=std::string::npos) {
        //        cout << found << endl;
        if (tmp_found+3 == found) count++;
        else count = 1;
        if (count > max_count) {
            ret.clear();
            max_count = count;
            string hoge = findw(found-count*3,input);
//            cout << "found = " << found << "hoge = " << hoge << endl;
            if (hoge != "") ret.push_back(hoge);
            else max_count = 0;
        }
        else if (max_count == count) {
            string hoge = findw(found-count*3,input);
//            cout << "found = " << found << "hoge = " << hoge << endl;
            if (hoge != "") ret.push_back(hoge);
        }
        tmp_found = found;
        found += 3;
    }
    for (int i = 0; i < ret.size(); i++) {
        cout << ret[i] << endl;
    }
    if (ret.size() == 0) cout << "" << endl;
    return 0;
}
0