結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー SSRSSSRS
提出日時 2022-10-14 22:33:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,189 ms / 3,000 ms
コード長 1,736 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 175,392 KB
実行使用メモリ 56,960 KB
最終ジャッジ日時 2023-09-08 22:44:01
合計ジャッジ時間 61,157 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 533 ms
24,724 KB
testcase_03 AC 716 ms
33,888 KB
testcase_04 AC 592 ms
24,136 KB
testcase_05 AC 412 ms
14,960 KB
testcase_06 AC 647 ms
25,812 KB
testcase_07 AC 929 ms
46,860 KB
testcase_08 AC 183 ms
6,972 KB
testcase_09 AC 758 ms
37,456 KB
testcase_10 AC 246 ms
10,976 KB
testcase_11 AC 213 ms
15,472 KB
testcase_12 AC 437 ms
22,768 KB
testcase_13 AC 843 ms
42,512 KB
testcase_14 AC 436 ms
19,200 KB
testcase_15 AC 781 ms
27,260 KB
testcase_16 AC 1,173 ms
43,132 KB
testcase_17 AC 608 ms
31,300 KB
testcase_18 AC 1,052 ms
45,752 KB
testcase_19 AC 310 ms
15,440 KB
testcase_20 AC 1,099 ms
45,488 KB
testcase_21 AC 319 ms
9,900 KB
testcase_22 AC 1,189 ms
49,088 KB
testcase_23 AC 1,119 ms
48,764 KB
testcase_24 AC 1,129 ms
48,772 KB
testcase_25 AC 1,117 ms
49,108 KB
testcase_26 AC 1,163 ms
48,864 KB
testcase_27 AC 1,126 ms
48,844 KB
testcase_28 AC 1,179 ms
48,948 KB
testcase_29 AC 1,174 ms
48,852 KB
testcase_30 AC 1,161 ms
49,076 KB
testcase_31 AC 1,154 ms
48,840 KB
testcase_32 AC 1,164 ms
48,884 KB
testcase_33 AC 1,145 ms
48,944 KB
testcase_34 AC 1,153 ms
48,840 KB
testcase_35 AC 1,183 ms
48,768 KB
testcase_36 AC 1,185 ms
48,772 KB
testcase_37 AC 1,161 ms
48,804 KB
testcase_38 AC 1,150 ms
48,768 KB
testcase_39 AC 1,172 ms
48,916 KB
testcase_40 AC 1,164 ms
48,812 KB
testcase_41 AC 1,110 ms
48,784 KB
testcase_42 AC 684 ms
20,212 KB
testcase_43 AC 706 ms
20,020 KB
testcase_44 AC 686 ms
20,012 KB
testcase_45 AC 678 ms
20,160 KB
testcase_46 AC 647 ms
20,236 KB
testcase_47 AC 1,007 ms
52,120 KB
testcase_48 AC 986 ms
52,152 KB
testcase_49 AC 1,002 ms
51,984 KB
testcase_50 AC 984 ms
51,976 KB
testcase_51 AC 979 ms
51,916 KB
testcase_52 AC 795 ms
56,880 KB
testcase_53 AC 819 ms
56,960 KB
testcase_54 AC 824 ms
56,784 KB
testcase_55 AC 1,028 ms
50,056 KB
testcase_56 AC 998 ms
50,132 KB
testcase_57 AC 1,032 ms
50,060 KB
testcase_58 AC 56 ms
8,260 KB
testcase_59 AC 1,164 ms
53,164 KB
testcase_60 AC 172 ms
6,476 KB
testcase_61 AC 1,015 ms
50,260 KB
testcase_62 AC 15 ms
4,380 KB
testcase_63 AC 212 ms
7,000 KB
testcase_64 AC 197 ms
7,064 KB
testcase_65 AC 234 ms
7,260 KB
testcase_66 AC 1,013 ms
49,860 KB
testcase_67 AC 338 ms
9,168 KB
testcase_68 AC 75 ms
5,332 KB
testcase_69 AC 335 ms
9,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long BASE = 100000000;
const unsigned long long M30 = ((unsigned long long) 1 << 30) - 1;
const unsigned long long M31 = ((unsigned long long) 1 << 31) - 1;
const unsigned long long MOD = ((unsigned long long) 1 << 61) - 1;
unsigned long long modulo(unsigned long long x){
  unsigned long long xu = x >> 61;
  unsigned long long xd = x & MOD;
  unsigned long long res = xu + xd;
  if (res >= MOD){
    res -= MOD;
  }
  return res;
}
unsigned long long mul(unsigned long long a, unsigned long long b){
  unsigned long long au = a >> 31;
  unsigned long long ad = a & M31;
  unsigned long long bu = b >> 31;
  unsigned long long bd = b & M31;
  unsigned long long mid = au * bd + ad * bu;
  unsigned long long midu = mid >> 30;
  unsigned long long midd = mid & M30;
  return modulo(au * bu * 2 + midu + (midd << 31) + ad * bd);
}
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  set<unsigned long long> st;
  for (int i = 0; i < N; i++){
    int L = S[i].size();
    vector<long long> POW(L);
    POW[0] = 1;
    for (int j = 1; j < L; j++){
      POW[j] = mul(POW[j - 1], BASE);
    }
    unsigned long long sum = 0;
    for (int j = 0; j < L; j++){
      sum = modulo(sum + mul(S[i][j], POW[j]));
    }
    if (st.count(sum) == 1){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    st.insert(sum);
    for (int j = 0; j < L - 1; j++){
      unsigned long long sum2 = sum;
      sum2 += MOD - mul(S[i][j], POW[j]);
      sum2 += MOD - mul(S[i][j + 1], POW[j + 1]);
      sum2 += mul(S[i][j], POW[j + 1]);
      sum2 += mul(S[i][j + 1], POW[j]);
      st.insert(modulo(sum2));
    }
  }
}
0