結果

問題 No.342 一番ワロタww
ユーザー data9824data9824
提出日時 2016-04-03 23:22:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 64,296 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 11:05:49
合計ジャッジ時間 1,075 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

static const char w[] = { (char)0xEF, (char)0xBD, (char)0x97 };

int main() {
	string s;
	cin >> s;
	vector<size_t> wBegins;
	vector<size_t> wEnds;
	vector<size_t> wCounts;
	bool readingW = false;
	size_t nextWIndex = 0;
	size_t wBegin = 0;
	size_t wEnd = 0;
	size_t wCount = 0;
	for (size_t i = 0; i < s.size() + 1; ++i) {
		char ch = s.c_str()[i];
		if (readingW) {
			if (ch == w[nextWIndex]) {
				++nextWIndex;
				if (nextWIndex == 3) {
					nextWIndex = 0;
					wEnd = i + 1;
					++wCount;
				}
			} else {
				readingW = false;
				if (wCount > 0) {
					wBegins.push_back(wBegin);
					wEnds.push_back(wEnd);
					wCounts.push_back(wCount);
				}
			}
		} else {
			if (ch == w[0]) {
				readingW = true;
				nextWIndex = 1;
				wBegin = i;
				wCount = 0;
			}
		}
	}
	if (wCounts.size() == 0) {
		return 0;
	}
	size_t maxWCount = *max_element(wCounts.begin(), wCounts.end());
	for (size_t i = 0; i < wCounts.size(); ++i) {
		if (wCounts[i] == maxWCount) {
			if (i == 0) {
				if (wBegins[i] > 0) {
					cout << s.substr(0, wBegins[i]) << endl;
				}
			} else {
				cout << s.substr(wEnds[i - 1], wBegins[i] - wEnds[i - 1]) << endl;
			}
		}
	}
	return 0;
}
0