結果

問題 No.341 沈黙の期間
ユーザー alpha_virginisalpha_virginis
提出日時 2016-02-12 22:24:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 940 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 66,396 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 02:47:14
合計ジャッジ時間 1,381 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

int main() {
  char str[1000];
  scanf("%s", str);

  int str2[1000];
  u8toi(str, str2);

  char t[10] = "…";
  int t2[10];
  u8toi(t, t2);
  int c = t2[0];
  int res = 0;
  int temp = 0;
  for(int i = 0; str2[i] != 0; ++i) {
    if( str2[i] == c ) {
      temp += 1;
    }
    else {
      temp = 0;
    }
    res = std::max(temp, res);
  }

  std::cout << res << std::endl;

  return 0;
}
0