結果

問題 No.3110 Like CPCTF?
ユーザー テナガザル
提出日時 2025-04-19 01:39:42
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 99,448 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-19 01:39:44
合計ジャッジ時間 1,483 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 2; j < n; ++j)
    {
      if (s[i] != s[j]) continue;
      for (int a = i + 1; a < j; ++a)
      {
        if (s[a] == s[i]) continue;
        for (int b = j + 1; b < n; ++b)
        {
          if (s[a] == s[b] || s[i] == s[b]) continue;
          for (int c = b + 1; c < n; ++c)
          {
            if (s[a] == s[c] || s[b] == s[c] || s[i] == s[c]) continue;
            ++ans;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
0