結果

問題 No.2593 Reorder and Mod 120
ユーザー ochiaigawaochiaigawa
提出日時 2023-12-21 12:42:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 2,464 ms
コンパイル使用メモリ 208,552 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-21 12:43:46
合計ジャッジ時間 48,163 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,519 ms
6,676 KB
testcase_01 AC 1,509 ms
6,676 KB
testcase_02 AC 1,521 ms
6,676 KB
testcase_03 AC 1,517 ms
6,676 KB
testcase_04 AC 1,513 ms
6,676 KB
testcase_05 AC 1,505 ms
6,676 KB
testcase_06 AC 1,513 ms
6,676 KB
testcase_07 AC 1,506 ms
6,676 KB
testcase_08 AC 1,479 ms
6,676 KB
testcase_09 AC 1,496 ms
6,676 KB
testcase_10 AC 1,508 ms
6,676 KB
testcase_11 AC 1,525 ms
6,676 KB
testcase_12 AC 1,528 ms
6,676 KB
testcase_13 AC 1,661 ms
6,676 KB
testcase_14 AC 1,586 ms
6,676 KB
testcase_15 AC 1,616 ms
6,676 KB
testcase_16 AC 1,560 ms
6,676 KB
testcase_17 AC 1,601 ms
6,676 KB
testcase_18 AC 1,558 ms
6,676 KB
testcase_19 AC 1,680 ms
6,676 KB
testcase_20 AC 1,711 ms
6,676 KB
testcase_21 AC 1,711 ms
6,676 KB
testcase_22 AC 1,713 ms
6,676 KB
testcase_23 AC 1,736 ms
6,676 KB
testcase_24 AC 1,688 ms
6,676 KB
testcase_25 AC 1,711 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 < 35000000; 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 += 600000;
    now %= 120;
    can[now] = true;
  }
  cout << accumulate(can.begin(), can.end(), 0) << '\n';
  return 0;
}
0