結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
yuusti
|
| 提出日時 | 2015-03-24 18:58:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,617 bytes |
| コンパイル時間 | 690 ms |
| コンパイル使用メモリ | 91,756 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-29 00:33:23 |
| 合計ジャッジ時間 | 1,179 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 8 |
ソースコード
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>
#ifdef _MSC_VER
#include <agents.h>
#endif
#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int mod_pow(long long x, long long n, long long p){
long long res = 1 % p;
x %= p;
while (n){
if (n & 1) res = res*x%p;
x = x*x%p;
n /= 2;
}
return res;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(20);
string s;
cin >> s;
int cnt[256] = {};
for (auto c : s) cnt[c]++;
int n = s.size();
const int m = 573;
vector<int> rem;
vector<int> pf = { 3, 191 };
for (int p : pf){
ll x = 1;
rep(i, 256){
FOR(j, 1, cnt[i] + 1){
x *= j;
x %= p;
}
}
ll y = 1;
FOR(i, 1, n + 1) y = y*i%p;
int k = y * mod_pow(x, p - 2, p) % p;
if (x == y) k = 1;
rem.push_back(k);
}
rep(i, m){
if (i % pf[0] == rem[0] && i % pf[1] == rem[1]){
cout << (i+m-1)%m << endl;
break;
}
}
}
yuusti