Submission

Status:
PPPPPPPTPTPPPPPPPPPP

Score: 90

User: devilpoohs

Problemset: สุ่มสลับ

Language: cpp

Time: 0.195 second

Submitted On: 2024-11-29 17:28:51

#include<bits/stdc++.h>
using namespace std;
string ans;
int n;
bool chk(vector<char> str){
	for(int i=0;i<n;i++){
		if(str[i]!=ans[i]){
			return false ;
		}
	}
	return true ;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;

	vector<char> str(n) ;
	for(int i=0;i<n;i++){
		str[i]+=('A'+i) ;
	//	cout << str[i];
	}
	cin>>ans ;
	int count=0 ;
	do{
		count++ ;
		if(chk(str)){
			cout << count ;
			break ;
		}
//		for(int i=0;i<n;i++){
//			cout << str[i] ;
//		}
	}while(next_permutation(str.begin(),str.end()));
//	cout << str ;
	return 0;
}