結果

問題 No.342 一番ワロタww
ユーザー alpha_virginisalpha_virginis
提出日時 2016-02-12 23:04:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,267 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 85,168 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 03:23:44
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:58:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   58 |   scanf("%s", str);
      |   ~~~~~^~~~~~~~~~~

ソースコード

diff #

#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;
    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;
}
0