結果

問題 No.3655 Adjacent Pairs in Triplets
コンテスト
ユーザー nekoti
提出日時 2026-08-30 13:38:43
言語 C
(gcc 15.3.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 31 ms / 2,000 ms
+ 44µs
コード長 570 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,222 ms
コンパイル使用メモリ 36,864 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-30 13:39:32
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#define _DEBUG 0
#if _DEBUG
#endif

#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
  int scan;//scanf警告用
  int ans=0;
  int i, j;
  
  char s[200010];
  scan=scanf("%s",s);
  int slen=strlen(s);
  for(i=2; i<slen; i++)
  {
    int count[256]={0};
    count[s[i-2]]++;
    count[s[i-1]]++;
    count[s[i-0]]++;
    bool ok=true;
    for(j=0;j<256;j++)
    {
      if(3<=count[j]){ok=false;break;}
    }
    if(!(s[i-2]==s[i-1] || s[i-1]==s[i-0]))ok=false;
    if(ok)ans++;
  }
  printf("%d", ans);
  return scan-scan;
}
0