結果

問題 No.341 沈黙の期間
ユーザー どららどらら
提出日時 2016-05-03 20:47:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,015 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 85,576 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 11:03:30
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

class utf8_string {
  std::vector<std::string> str;
  int num_byte(const char &cc){
    unsigned char c = static_cast<unsigned char>(cc);
    if(c <= 0x7f) return 1;
    if(0xc0 <= c && c <= 0xcf) return 2;
    if(0xd0 <= c && c <= 0xdf) return 2;
    if(0xe0 <= c && c <= 0xef) return 3;
    if(0xf0 <= c && c <= 0xf7) return 4;
    if(0xf8 <= c && c <= 0xfb) return 5;
    return 6;
  }
  void init_str(const std::string &s){
    for(size_t i=0; i<s.length();){
      int n = num_byte(s[i]);
      str.push_back(s.substr(i,n));
      i += n;
    }
  }
public:
  utf8_string(const std::string &s){ init_str(s); }
  utf8_string(const char *p){
    std::string s(p);
    init_str(s);
  }
  
  size_t length() const { return str.size(); }
  std::string operator[](size_t idx) const {
    return str[idx];
  }
  bool operator==(const utf8_string &s){
    if(length() != s.length()) return false;
    for(size_t i=0; i<length(); i++){
      if(str[i] != s[i]) return false;
    }
    return true;
  }
  std::string substr(size_t begin, size_t len){
    std::string ret;
    for(size_t i=begin; i<begin+len; i++){
      if(i>=str.size()) break;
      ret += str[i];
    }
    return ret;
  }
};


int main(){
  string str;
  cin >> str;
  string pat = "…";

  utf8_string ustr(str);
  utf8_string upat(pat);

  int ret = 0;
  int now = 0;
  rep(i,ustr.length()){
    if(ustr[i] == upat[0]){
      now++;
      ret = max(ret, now);
    }else{
      now = 0;
    }
  }
  cout << ret << endl;
  
  return 0;
}
0