Submission

Status:

PPPPPPPTPTPPPPPPPPPP

Subtask/Task Score:

90/100

Score: 90

User: Kidmaiok

Problemset: สุ่มสลับ

Language: cpp

Time: 0.196 second

Submitted On: 2025-10-07 00:44:17

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

int main() {
    int n;
    string m;
    cin >> n >> m;

    if (m.size() > n) {
        
        return 0;
    }

    for (char c : m) {
        if (c > 'A' + n - 1) {
            
            return 0;
        }
    }

    string base = "";
    for (int i = 0; i < n; i++) base += char('A' + i);

    int rank = 1;
    do {
        if (base == m) {
            cout << rank;
            return 0;
        }
        rank++;
    } while (next_permutation(base.begin(), base.end()));

    
}