結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2016-02-12 23:29:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,512 bytes |
| コンパイル時間 | 989 ms |
| コンパイル使用メモリ | 85,276 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 04:59:28 |
| 合計ジャッジ時間 | 1,624 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%s", str);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <string.h>
void u8toi(char *str, int *array) {
int i;
int n = strlen(str);
for(i = 0; i < n; ++i) {
int flag = str[i];
int mask = ~flag;
mask |= (mask >> 1);
mask |= (mask >> 2);
mask |= (mask >> 4);
int res = str[i] & mask;
while( 0xC0 <= (unsigned char)flag ) {
i += 1;
flag <<= 1;
res <<= 6;
res |= str[i] & 0x3F;
}
*array++ = res;
}
*array++ = 0;
}
void itou8(int *array, char *str) {
int i;
while( *array != 0 ) {
int c = *array;
char str2[8];
int len = 0;
char c2;
if( c < 0x80 ) {
str2[0] = c;
len = 1;
}
else {
while( c != 0 ) {
c2 = (c & 0x3f);
str2[len] = c2;
len += 1;
c >>= 6;
}
}
if( len != 1 ) {
str2[len - 1] |= (0xff << (8 - len));
for(i = 0; i < len - 1; ++i) {
str2[i] |= 0x80;
}
}
for(i = len - 1; i >= 0; --i) {
*str++ = str2[i];
}
array += 1;
}
*str++ = 0;
}
int main() {
char str[1000];
scanf("%s", str);
int str2[1000];
u8toi(str, str2);
itou8(str2, str);
//printf("%s\n", str);
char t[100] = "w";
int t2[100];
u8toi(t, t2);
int tt = t2[0];
int temp = 0;
std::vector<int> ttstr;
std::vector<std::pair<int, std::vector<int>> > candi;
for(int i = 0; str2[i] != 0; ++i) {
if( str2[i] == tt ) {
temp += 1;
}
else {
if( temp != 0 ) {
if( ttstr.size() != 0 ) {
candi.push_back(std::pair<int, std::vector<int>>(temp, ttstr));
ttstr.clear();
}
}
temp = 0;
ttstr.push_back(str2[i]);
}
}
if( temp != 0 ) {
if( ttstr.size() != 0 ) {
candi.push_back(std::pair<int, std::vector<int>>(temp, ttstr));
ttstr.clear();
}
}
std::stable_sort(candi.begin(), candi.end());
int llen;
if( candi.size() != 0 ) {
llen = candi[candi.size()-1].first;
}
bool flag = true;
for(int i = 0; i < (int)candi.size(); ++i) {
if( candi[i].first != llen ) continue;
char res[1000];
int rest[1000];
for(int j = 0; j < (int)candi[i].second.size(); ++j) {
rest[j] = candi[i].second[j];
}
rest[candi[i].second.size()] = 0;
itou8(rest, res);
if( res[0] != '\0' ) {
flag = false;
printf("%s\n", res);
}
}
if( flag ) {
std::cout << std::endl;
}
return 0;
}
alpha_virginis