結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-23 00:13:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,177 bytes |
| コンパイル時間 | 590 ms |
| コンパイル使用メモリ | 68,388 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-29 00:18:22 |
| 合計ジャッジ時間 | 1,154 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 5 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <list>
using namespace std;
const int MOD = 573;
int main() {
string s;
cin >> s;
vector<int> alpha(26, 0);
int n = s.size();
char c;
for (int i = 0; i < n; i++) {
alpha[s[i] - 'A']++;
}
int exist = 0;
for (int i = 0; i < alpha.size(); i++) {
if (alpha[i] > 0) {
exist++;
}
}
if (exist == 1) {
cout << 0 << endl;
return 0;
}
list<int> product;
for (int i = 2; i <= n; i++) {
product.push_back(i);
}
list<int> devide;
for (int i = 0; i < alpha.size(); i++) {
for (int j = alpha[i]; j > 1; j--) {
devide.push_back(j);
}
}
devide.sort(greater<int>());
for (auto itd = devide.begin(); itd != devide.end(); itd++) {
for(auto itp = product.begin(); itp != product.end(); itp++) {
if (*itp == *itd) {
product.erase(itp);
break;
} else if (*itp %= *itd) {
*itp /= *itd;
product.sort();
break;
}
}
}
int ans = 1;
for(auto itp = product.begin(); itp != product.end(); itp++) {
ans = (ans * *itp) % MOD;
}
ans = (ans + MOD - 1) % MOD;
cout << ans << endl;
return 0;
}