結果

問題 No.342 一番ワロタww
ユーザー kpinkcatkpinkcat
提出日時 2023-11-16 19:01:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,772 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 113,012 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-16 19:01:02
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
#ifdef _WIN32
#include <Windows.h>
#endif


int cntByte(unsigned char cChar)
{
   int iByte;

   if ((cChar >= 0x00) && (cChar <= 0x7f)) {
       iByte = 1;
   } else if ((cChar >= 0xc2) && (cChar <= 0xdf)) {
       iByte = 2;
   } else if ((cChar >= 0xe0) && (cChar <= 0xef)) {
       iByte = 3;
   } else if ((cChar >= 0xf0) && (cChar <= 0xf7)) {
       iByte = 4;
   } else if ((cChar >= 0xf8) && (cChar <= 0xfb)) {
       iByte = 5;
   } else if ((cChar >= 0xfc) && (cChar <= 0xfd)) {
       iByte = 6;
   } else {
       iByte = 0;
   }

   return iByte;
}


int main()
{
    #ifdef _WIN32
        SetConsoleOutputCP(CP_UTF8);
        setvbuf(stdout, nullptr, _IOFBF, 1024);
    #endif
    int cnt = 0, max1 = 0, cbytes;
    string s, t, tmp = "";
    cin >> s;
    t = "w";
    vector<string> ans;
    string::size_type pos = 0;
    while (s.begin() + pos <= s.end()){
        cbytes = cntByte(s[pos]);
        if (s.substr(pos, cbytes) == t){
            cnt++;
        } else {
            if (cnt > 0 && cnt >= max1) {
                if (cnt == max1 && tmp.size() > 0) ans.push_back(tmp);
                else if (cnt > max1 && tmp.size() > 0){
                    ans.clear();
                    ans.push_back(tmp);
                }
                if (tmp.size()) max1 = cnt;
                cnt = 0;
                tmp = "";
            } else if (cnt > 0){
                cnt = 0;
                tmp = "";
            }
            tmp += s.substr(pos, cbytes);
        }
        pos += cbytes;
    }
    for (auto x : ans){
        cout << x << endl;;
    }
}
0