結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | butsurizuki |
提出日時 | 2022-10-07 10:18:35 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,311 ms / 3,000 ms |
コード長 | 2,252 bytes |
コンパイル時間 | 10,094 ms |
コンパイル使用メモリ | 336,752 KB |
実行使用メモリ | 58,800 KB |
最終ジャッジ日時 | 2024-12-22 17:15:02 |
合計ジャッジ時間 | 71,706 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 395 ms
28,224 KB |
testcase_03 | AC | 634 ms
37,932 KB |
testcase_04 | AC | 373 ms
28,080 KB |
testcase_05 | AC | 169 ms
18,064 KB |
testcase_06 | AC | 422 ms
29,800 KB |
testcase_07 | AC | 1,092 ms
50,716 KB |
testcase_08 | AC | 36 ms
8,788 KB |
testcase_09 | AC | 801 ms
41,392 KB |
testcase_10 | AC | 111 ms
13,316 KB |
testcase_11 | AC | 171 ms
17,208 KB |
testcase_12 | AC | 360 ms
25,712 KB |
testcase_13 | AC | 953 ms
47,268 KB |
testcase_14 | AC | 261 ms
22,724 KB |
testcase_15 | AC | 482 ms
31,732 KB |
testcase_16 | AC | 886 ms
48,404 KB |
testcase_17 | AC | 507 ms
34,008 KB |
testcase_18 | AC | 1,034 ms
50,252 KB |
testcase_19 | AC | 186 ms
17,988 KB |
testcase_20 | AC | 992 ms
50,400 KB |
testcase_21 | AC | 66 ms
12,556 KB |
testcase_22 | AC | 1,092 ms
54,852 KB |
testcase_23 | AC | 1,059 ms
54,852 KB |
testcase_24 | AC | 1,046 ms
54,724 KB |
testcase_25 | AC | 1,148 ms
54,852 KB |
testcase_26 | AC | 1,068 ms
54,852 KB |
testcase_27 | AC | 1,182 ms
54,852 KB |
testcase_28 | AC | 1,119 ms
54,724 KB |
testcase_29 | AC | 1,135 ms
54,724 KB |
testcase_30 | AC | 1,105 ms
54,724 KB |
testcase_31 | AC | 1,178 ms
54,856 KB |
testcase_32 | AC | 1,190 ms
54,848 KB |
testcase_33 | AC | 1,149 ms
54,856 KB |
testcase_34 | AC | 1,182 ms
54,856 KB |
testcase_35 | AC | 1,126 ms
54,852 KB |
testcase_36 | AC | 1,113 ms
54,852 KB |
testcase_37 | AC | 1,145 ms
54,724 KB |
testcase_38 | AC | 1,155 ms
54,852 KB |
testcase_39 | AC | 1,134 ms
54,852 KB |
testcase_40 | AC | 1,132 ms
54,728 KB |
testcase_41 | AC | 1,153 ms
54,724 KB |
testcase_42 | AC | 568 ms
25,452 KB |
testcase_43 | AC | 541 ms
25,456 KB |
testcase_44 | AC | 594 ms
25,452 KB |
testcase_45 | AC | 584 ms
25,328 KB |
testcase_46 | AC | 599 ms
25,452 KB |
testcase_47 | AC | 1,272 ms
56,828 KB |
testcase_48 | AC | 1,221 ms
56,828 KB |
testcase_49 | AC | 1,257 ms
56,828 KB |
testcase_50 | AC | 1,256 ms
56,828 KB |
testcase_51 | AC | 1,311 ms
56,700 KB |
testcase_52 | AC | 1,184 ms
54,360 KB |
testcase_53 | AC | 1,181 ms
54,428 KB |
testcase_54 | AC | 1,178 ms
54,304 KB |
testcase_55 | AC | 1,171 ms
53,388 KB |
testcase_56 | AC | 1,139 ms
53,384 KB |
testcase_57 | AC | 1,170 ms
53,512 KB |
testcase_58 | AC | 62 ms
9,348 KB |
testcase_59 | AC | 1,236 ms
58,800 KB |
testcase_60 | AC | 34 ms
8,968 KB |
testcase_61 | AC | 1,195 ms
53,512 KB |
testcase_62 | AC | 8 ms
5,248 KB |
testcase_63 | AC | 142 ms
14,720 KB |
testcase_64 | AC | 132 ms
14,676 KB |
testcase_65 | AC | 170 ms
14,724 KB |
testcase_66 | AC | 1,189 ms
53,008 KB |
testcase_67 | AC | 91 ms
17,992 KB |
testcase_68 | AC | 82 ms
8,456 KB |
testcase_69 | AC | 81 ms
17,992 KB |
ソースコード
#include "testlib.h" #include <bits/stdc++.h> using namespace std; // Safer-Faster-RollingHash // https://qiita.com/keymoon/items/11fac5627672a6d6a9f6 // https://atcoder.jp/contests/abc141/submissions/7717102 typedef unsigned long long int ull; const ull MASK30 = (1ull << 30) - 1; const ull MASK31 = (1ull << 31) - 1; const ull MOD = (1ull << 61) - 1; const ull MASK61 = MOD; //mod 2^61-1を計算する関数 ull CalcMod(ull x) { ull xu = x >> 61; ull xd = x & MASK61; ull res = xu + xd; if (res >= MOD) res -= MOD; return res; } //a*b mod 2^61-1を返す関数(最後にModを取る) ull Mul(ull a, ull b) { ull au = a >> 31; ull ad = a & MASK31; ull bu = b >> 31; ull bd = b & MASK31; ull mid = ad * bu + au * bd; ull midu = mid >> 30; ull midd = mid & MASK30; return CalcMod(au * bu * 2 + midu + (midd << 31) + ad * bd); } ull hBase; void genBase(mt19937_64 &eg){ hBase=CalcMod((ull)eg()); } int main(){ random_device seed_gen; mt19937_64 engine(seed_gen()); registerValidation(); int n=inf.readInt(1,200000);inf.readEoln(); vector<string> s(n); int sigl=0; for(int i=0;i<n;i++){ s[i]=inf.readToken();inf.readEoln(); sigl+=s[i].size(); ensuref(sigl<=1000000,"too long input"); for(auto &nx : s[i]){ ensuref('a'<=nx && nx<='z',"invalid char"); } } inf.readEof(); vector<int> res(n,1); for(int tr=0;tr<1;tr++){ genBase(engine); set<ull> st; for(int i=0;i<n;i++){ ull ordHash=0; for(auto &nx : s[i]){ ordHash=CalcMod(Mul(ordHash,hBase)+((ull)nx)); } if(st.find(ordHash)==st.end()){res[i]=0;} // cout << "Cur : " << ordHash << "\n"; st.insert(ordHash); ull pos=1; for(int j=s[i].size()-1;j>0;j--){ ull npos=Mul(pos,hBase); ull subdel =CalcMod(Mul(pos,((ull)s[i][j]))+Mul(npos,((ull)s[i][j-1]))); ull addel =CalcMod(Mul(pos,((ull)s[i][j-1]))+Mul(npos,((ull)s[i][j]))); ull curHash=CalcMod(ordHash+MOD-subdel+addel); st.insert(curHash); // cout << "Swap " << j << " : " << curHash << "\n"; pos=npos; } } } for(auto &nx : res){ if(nx==1){cout << "Yes\n";} else{cout << "No\n";} } return 0; }