結果
問題 |
No.3110 Like CPCTF?
|
ユーザー |
|
提出日時 | 2025-04-18 22:07:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 983 bytes |
コンパイル時間 | 982 ms |
コンパイル使用メモリ | 83,064 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-18 22:07:46 |
合計ジャッジ時間 | 2,012 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int N; string S; cin >> N >> S; if (N < 5) { cout << 0 << endl; return 0; } int ans = 0; vector<int> index(N); for (int i = 0; i < N; ++i) index[i] = i; vector<bool> select(N, false); fill(select.end() - 5, select.end(), true); do { vector<int> comb; for (int i = 0; i < N; ++i) { if (select[i]) comb.push_back(index[i]); } sort(comb.begin(), comb.end()); char a = S[comb[0]]; char b = S[comb[1]]; char c = S[comb[2]]; char d = S[comb[3]]; char e = S[comb[4]]; if (a == c && b != a && d != a && e != a && b != c && b != d && b != e && d != e && d != c && e != c){ ans++; } } while (next_permutation(select.begin(), select.end())); cout << ans << endl; return 0; }