結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー umezoumezo
提出日時 2022-10-15 01:06:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,360 ms / 3,000 ms
コード長 1,128 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 209,832 KB
実行使用メモリ 83,640 KB
最終ジャッジ日時 2023-09-09 01:39:17
合計ジャッジ時間 63,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
18,800 KB
testcase_01 AC 29 ms
18,724 KB
testcase_02 AC 479 ms
45,984 KB
testcase_03 AC 697 ms
58,008 KB
testcase_04 AC 490 ms
45,640 KB
testcase_05 AC 264 ms
32,704 KB
testcase_06 AC 519 ms
47,048 KB
testcase_07 AC 1,031 ms
76,100 KB
testcase_08 AC 74 ms
23,008 KB
testcase_09 AC 767 ms
63,416 KB
testcase_10 AC 175 ms
28,236 KB
testcase_11 AC 230 ms
34,688 KB
testcase_12 AC 432 ms
43,744 KB
testcase_13 AC 924 ms
70,176 KB
testcase_14 AC 361 ms
38,744 KB
testcase_15 AC 576 ms
48,964 KB
testcase_16 AC 976 ms
69,936 KB
testcase_17 AC 602 ms
55,744 KB
testcase_18 AC 1,006 ms
74,772 KB
testcase_19 AC 260 ms
34,092 KB
testcase_20 AC 1,123 ms
73,624 KB
testcase_21 AC 120 ms
25,732 KB
testcase_22 AC 1,127 ms
77,800 KB
testcase_23 AC 1,100 ms
77,788 KB
testcase_24 AC 1,091 ms
77,784 KB
testcase_25 AC 1,143 ms
77,732 KB
testcase_26 AC 1,252 ms
77,748 KB
testcase_27 AC 1,143 ms
77,744 KB
testcase_28 AC 1,129 ms
77,740 KB
testcase_29 AC 1,111 ms
77,740 KB
testcase_30 AC 1,118 ms
77,796 KB
testcase_31 AC 1,114 ms
77,784 KB
testcase_32 AC 1,070 ms
77,868 KB
testcase_33 AC 1,098 ms
77,848 KB
testcase_34 AC 1,087 ms
77,796 KB
testcase_35 AC 1,141 ms
77,804 KB
testcase_36 AC 1,244 ms
77,748 KB
testcase_37 AC 1,130 ms
77,796 KB
testcase_38 AC 1,119 ms
77,860 KB
testcase_39 AC 1,170 ms
77,788 KB
testcase_40 AC 1,307 ms
77,800 KB
testcase_41 AC 1,160 ms
77,784 KB
testcase_42 AC 799 ms
40,380 KB
testcase_43 AC 763 ms
40,388 KB
testcase_44 AC 801 ms
40,400 KB
testcase_45 AC 834 ms
40,644 KB
testcase_46 AC 835 ms
40,508 KB
testcase_47 AC 1,211 ms
83,156 KB
testcase_48 AC 1,237 ms
83,544 KB
testcase_49 AC 1,217 ms
83,288 KB
testcase_50 AC 1,190 ms
83,200 KB
testcase_51 AC 1,208 ms
83,640 KB
testcase_52 AC 1,155 ms
79,900 KB
testcase_53 AC 1,168 ms
79,768 KB
testcase_54 AC 1,154 ms
79,696 KB
testcase_55 AC 1,355 ms
79,792 KB
testcase_56 AC 1,360 ms
80,116 KB
testcase_57 AC 1,039 ms
80,072 KB
testcase_58 AC 128 ms
19,804 KB
testcase_59 AC 929 ms
83,408 KB
testcase_60 AC 63 ms
22,372 KB
testcase_61 AC 1,100 ms
79,992 KB
testcase_62 AC 34 ms
19,132 KB
testcase_63 AC 221 ms
22,744 KB
testcase_64 AC 201 ms
22,684 KB
testcase_65 AC 244 ms
23,252 KB
testcase_66 AC 1,058 ms
79,276 KB
testcase_67 AC 141 ms
24,940 KB
testcase_68 AC 142 ms
19,856 KB
testcase_69 AC 136 ms
24,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

ll MOD1=464975561;
ll MOD2=219930517;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  random_device rd;
  mt19937_64 rnd(rd());    
  uniform_int_distribution<ll> dist_n1(1000001,99999999),dist_n2(1000001,99999999);
  
  int n;
  cin>>n;
  vector<string> S(n);
  rep(i,n) cin>>S[i];
  
  vector<ll> A(1000100),B(1000100);
  rep(i,1000100){
    ll a=dist_n1(rnd),b=dist_n2(rnd);
    A[i]=a,B[i]=b;
  }
  
  set<pair<ll,ll>> s;
  rep(i,n){
    ll sum1=0,sum2=0;
    int k=S[i].size();
    rep(j,k){
      sum1=(sum1+A[j]*S[i][j]%MOD1)%MOD1;
      sum2=(sum2+B[j]*S[i][j]%MOD2)%MOD2;
    }
    if(s.count({sum1,sum2})) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    s.insert({sum1,sum2});
    rep(j,k-1){
      ll a=(sum1-A[j]*S[i][j]%MOD1-A[j+1]*S[i][j+1]%MOD1+A[j]*S[i][j+1]+A[j+1]*S[i][j]+2*MOD1)%MOD1;
      ll b=(sum2-B[j]*S[i][j]%MOD2-B[j+1]*S[i][j+1]%MOD2+B[j]*S[i][j+1]+B[j+1]*S[i][j]+2*MOD2)%MOD2;
      s.insert({a,b});
    }
  }

  return 0;
}
0