結果
| 問題 |
No.3110 Like CPCTF?
|
| コンテスト | |
| ユーザー |
eiya5498513
|
| 提出日時 | 2025-04-19 17:40:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,643 bytes |
| コンパイル時間 | 3,965 ms |
| コンパイル使用メモリ | 212,288 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-19 17:40:56 |
| 合計ジャッジ時間 | 4,863 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 26450 )
#pragma warning( disable : 26451 )
#pragma warning( disable : 26498 )
#pragma warning( disable : 4459 )
#endif
#include <atcoder/all>
#ifdef _MSC_VER
#pragma warning( pop )
#endif
auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;
int countr[40][40] = {};
int main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in.tie(nullptr);
out.tie(nullptr);
int n;
in >> n;
std::string S;
in >> S;
std::reverse(S.begin(), S.end());
for (int i = S.size() - 1; i >= 0; --i) {
if (i >= 40) { throw 0; }
for (int j = 0; j < 40; j++) {
countr[i][j] = countr[i+1][j];
}
countr[i][S[i] - 'A'] += 1;
}
int64_t count_sum = 0;
for (size_t i = 0; i < S.size(); i++)
for (size_t j = i + 1; j < S.size(); j++) if (S[i] != S[j])
for (size_t k = j + 1; k < S.size(); k++) if (S[i] != S[k] && S[j] != S[k])
for (size_t l = k + 1; l < S.size(); l++) if (S[i] != S[l] && S[j] != S[l] && S[k] != S[l])
{
count_sum += countr[l + 1][S[k] - 'A'];
}
out << count_sum << endl;
}
#endif
eiya5498513