結果

問題 No.342 一番ワロタww
ユーザー dazydazy
提出日時 2018-07-19 02:08:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,336 bytes
コンパイル時間 3,500 ms
コンパイル使用メモリ 174,180 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-22 19:02:36
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define print(x) cout << x << "\n"
typedef vector<int> vi;

bool check(char c0, char c1, char c2) {
    string cs = "w";
    return c0==cs[0] && c1==cs[1] && c2==cs[2];
}

int main() {
    fastcin;
    string s;
    cin >> s;
    int con = 0, ano = 0;
    vi si, tmp;
    for(int i=0; i<s.size(); i+=3) {
        if(check(s[i], s[i+1], s[i+2])) {
            if(ano>0) {
                si.push_back(-ano);
                ano = 0;
            }
            con++;
        } else {
            if(con>0) {
                si.push_back(con);
                con = 0;
            }
            ano++;
        }
    }
    if(con>0) si.push_back(con);
    if(ano>0) si.push_back(-ano);
    tmp = si;
    if(tmp[0]>0) tmp[0] = -tmp[0];
    sort(tmp.rbegin(), tmp.rend());
    int m = tmp[0], cnt = 1;
    rep(i, 1, tmp.size()) {
        if(m!=tmp[i]) break;
        else cnt++;
    }
    int sidx = 0, siidx = 0;
    while(cnt>0) {
        if(siidx!=0 && si[siidx]==m) {
            string p = s.substr(sidx-abs(si[siidx-1])*3, abs(si[siidx-1])*3);
            print(p);
            cnt--;
        } 
        sidx += 3*abs(si[siidx]);
        siidx++;
    }
    return 0;
}
0