結果

問題 No.2593 Reorder and Mod 120
ユーザー ochiaigawaochiaigawa
提出日時 2023-12-22 19:14:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 208,436 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-22 19:15:21
合計ジャッジ時間 47,768 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,546 ms
6,676 KB
testcase_01 AC 1,537 ms
6,676 KB
testcase_02 AC 1,537 ms
6,676 KB
testcase_03 AC 1,539 ms
6,676 KB
testcase_04 AC 1,517 ms
6,676 KB
testcase_05 AC 1,548 ms
6,676 KB
testcase_06 AC 1,539 ms
6,676 KB
testcase_07 AC 1,534 ms
6,676 KB
testcase_08 AC 1,517 ms
6,676 KB
testcase_09 AC 1,515 ms
6,676 KB
testcase_10 AC 1,535 ms
6,676 KB
testcase_11 AC 1,553 ms
6,676 KB
testcase_12 AC 1,572 ms
6,676 KB
testcase_13 AC 1,659 ms
6,676 KB
testcase_14 AC 1,608 ms
6,676 KB
testcase_15 AC 1,632 ms
6,676 KB
testcase_16 AC 1,578 ms
6,676 KB
testcase_17 AC 1,599 ms
6,676 KB
testcase_18 AC 1,565 ms
6,676 KB
testcase_19 AC 1,658 ms
6,676 KB
testcase_20 AC 1,672 ms
6,676 KB
testcase_21 AC 1,693 ms
6,676 KB
testcase_22 AC 1,696 ms
6,676 KB
testcase_23 AC 1,695 ms
6,676 KB
testcase_24 AC 1,694 ms
6,676 KB
testcase_25 AC 1,667 ms
6,676 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
random_device rnd;
mt19937 mt(rnd());
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<bool> can(120, false);
  vector<int> pom(N, 1);
  for(int i = N - 2; i >= 0; i--) {
    pom[i] = pom[i + 1] * 10 % 120;
  }
  int now = 0;
  for(int i = N - 1; i >= 0; i--) {
    now += (S[i] - '0') * pom[i];
    now %= 120;
  }
  for(int epoch = 0; epoch < 37000000; epoch++) {
    int u = mt() % N;
    int v = mt() % N;
    now -= (S[u] - '0') * pom[u];
    now -= (S[v] - '0') * pom[v];
    swap(S[u], S[v]);
    now += (S[u] - '0') * pom[u];
    now += (S[v] - '0') * pom[v];
    now %= 120;
    now = (now + 120) % 120;
    can[now] = true;
  }
  cout << accumulate(can.begin(), can.end(), 0) << '\n';
  return 0;
}
0