結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2016-05-04 00:50:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,416 bytes |
| コンパイル時間 | 904 ms |
| コンパイル使用メモリ | 93,332 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 13:23:54 |
| 合計ジャッジ時間 | 1,749 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
class utf8_string {
std::vector<std::string> str;
int num_byte(const char &cc){
unsigned char c = static_cast<unsigned char>(cc);
if(c <= 0x7f) return 1;
if(0xc0 <= c && c <= 0xcf) return 2;
if(0xd0 <= c && c <= 0xdf) return 2;
if(0xe0 <= c && c <= 0xef) return 3;
if(0xf0 <= c && c <= 0xf7) return 4;
if(0xf8 <= c && c <= 0xfb) return 5;
return 6;
}
void init_str(const std::string &s){
for(size_t i=0; i<s.length();){
int n = num_byte(s[i]);
str.push_back(s.substr(i,n));
i += n;
}
}
public:
utf8_string(const std::string &s){ init_str(s); }
utf8_string(const char *p){
std::string s(p);
init_str(s);
}
size_t length() const { return str.size(); }
std::string operator[](size_t idx) const {
return str[idx];
}
bool operator==(const utf8_string &s){
if(length() != s.length()) return false;
for(size_t i=0; i<length(); i++){
if(str[i] != s[i]) return false;
}
return true;
}
std::string substr(size_t begin, size_t len){
std::string ret;
for(size_t i=begin; i<begin+len; i++){
if(i>=str.size()) break;
ret += str[i];
}
return ret;
}
};
int main(){
string str;
cin >> str;
utf8_string ustr(str);
utf8_string upat("w");
vector< pair<string,int> > v;
string now = "";
rep(i,ustr.length()){
if(ustr[i] == upat[0]){
int p = 0;
while(i<ustr.length() && ustr[i]==upat[0]){
p++;
i++;
}
i--;
if(now != "") v.push_back(make_pair(now, p));
}else{
int st = i;
int p = 0;
while(i<ustr.length() && ustr[i] != upat[0]){
p++;
i++;
}
i--;
now = ustr.substr(st, p);
}
}
int mx = -1;
rep(i,v.size()) mx = max(mx, v[i].second);
rep(i,v.size()){
if(v[i].second == mx){
cout << v[i].first << endl;
}
}
return 0;
}
どらら