結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
anta
|
| 提出日時 | 2016-02-12 23:33:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 3,521 bytes |
| コンパイル時間 | 731 ms |
| コンパイル使用メモリ | 89,080 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 13:13:47 |
| 合計ジャッジ時間 | 1,427 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 |
ソースコード
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
unsigned errorUTF8Char(unsigned char leadingByte) {
return 0xdc00U + leadingByte;
}
template<typename It>
unsigned decodeUTF8Char(It &it) {
unsigned char lb = *it; ++ it; //leading byte
int len;
if((lb & 0x80) == 0) len = 1;
else if((lb & 0xe0) == 0xc0) len = 2;
else if((lb & 0xf0) == 0xe0) len = 3;
else if((lb & 0xf8) == 0xf0) len = 4;
else if((lb & 0xfc) == 0xf8) len = 5;
else if((lb & 0xfe) == 0xfc) len = 6;
else return errorUTF8Char(lb);
unsigned code = len == 1 ? lb : lb & ((1 << (7 - len)) - 1);
for(int i = 1; i < len; ++ i) {
unsigned char byte = *it; ++ it;
if((byte & 0xc0) != 0x80) {
for(; i >= 1; -- i) -- it;
return errorUTF8Char(lb);
}
code = code << 6 | (byte & ~0x80U);
}
return code;
}
template<typename It>
int encodeUTF8Char(unsigned code, It &it) {
int len;
if(code <= 0x7fU) len = 1;
else if(code <= 0x7ffU) len = 2;
else if(code <= 0xffffU) len = 3;
else if(code <= 0x1fffffU) len = 4;
else if(code <= 0x3ffffffU) len = 5;
else if(code <= 0x7fffffffU) len = 6;
else return -1; //error
unsigned char lb = (unsigned char)(code >> ((len - 1) * 6));
if(len > 1) lb |= (unsigned char)(0xffU << (8 - len));
*it = lb; ++ it;
for(int i = 1; i < len; ++ i) {
*it = (unsigned char)(0x80 | (code >> ((len - 1 - i) * 6) & 0x3f));
++ it;
}
return len;
}
template<typename T>
vector<pair<T, int> > runLength(const T a[], int n) {
vector<pair<T, int> > r;
if(n <= 0) return r;
int cnt = 0;
for(int i = 0; i <= n; i ++) {
if(i == n || (i != 0 && a[i] != a[i - 1])) {
r.push_back(make_pair(a[i - 1], cnt));
cnt = 0;
}
cnt ++;
}
return r;
}
int main() {
string encoded;
while(cin >> encoded) {
vector<unsigned> S;
for(const char *p = encoded.c_str(); *p; )
S.push_back(decodeUTF8Char(p));
auto runs = runLength(S.data(), S.size());
int maxNum = 0;
rep(i, runs.size()) {
if(i != 0 && runs[i].first == u'w')
amax(maxNum, runs[i].second);
}
if(maxNum == 0 || maxNum == S.size()) {
puts("");
} else {
char buf[100 * 8 + 1];
char *it = buf;
rep(i, runs.size()) {
if(i != 0 && runs[i].first == u'w' && runs[i].second == maxNum) {
*it = 0;
puts(buf);
}
if(runs[i].first == u'w') {
it = buf;
} else {
rep(j, runs[i].second)
encodeUTF8Char(runs[i].first, it);
}
}
}
}
return 0;
}
anta