結果

問題 No.3110 Like CPCTF?
ユーザー MOTOHARU ONODERA
提出日時 2025-04-19 11:04:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 199,604 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-19 11:04:58
合計ジャッジ時間 3,102 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool check(string t){
	set<char> p;
	for(int i=0;i<5;i++){
		p.insert(t[i]);
	}
	if(t[0]==t[2]&&p.size()==4)return true;
	else return false;
}
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count=0;
	if(n<=4)cout << 0 << endl;
	else{
		for(int a=0;a<=n-5;a++){
			for(int b=a+1; b<=n-4;b++){
				for(int c=b+1; c<=n-3;c++){
					for(int d=c+1;d<=n-2;d++){
						for(int e=d+1;e<=n-1;e++){
							string w="";
							w+=s[a];
							w+=s[b];
							w+=s[c];
							w+=s[d];
							w+=s[e];
							if(check(w))count++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
}
0