結果
問題 |
No.342 一番ワロタww
|
ユーザー |
![]() |
提出日時 | 2016-02-12 23:18:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,352 bytes |
コンパイル時間 | 957 ms |
コンパイル使用メモリ | 85,312 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 04:54:45 |
合計ジャッジ時間 | 1,558 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:64:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | 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( ( c2 = (c & 0x3f) ) != 0 ) { 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); 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 ) { char sstr[1000]; candi.push_back(std::pair<int, std::vector<int>>(temp, ttstr)); ttstr.clear(); } temp = 0; ttstr.push_back(str2[i]); } } if( temp != 0 ) { char sstr[1000]; 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; } 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' ) { printf("%s\n", res); } } return 0; }