結果
問題 | No.2102 [Cherry Alpha *] Conditional Reflection |
ユーザー | houren |
提出日時 | 2022-12-22 11:46:01 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 462 ms / 3,000 ms |
コード長 | 1,593 bytes |
コンパイル時間 | 2,099 ms |
コンパイル使用メモリ | 175,452 KB |
実行使用メモリ | 28,128 KB |
最終ジャッジ日時 | 2024-11-18 03:19:53 |
合計ジャッジ時間 | 22,113 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
18,676 KB |
testcase_01 | AC | 15 ms
18,864 KB |
testcase_02 | AC | 196 ms
22,872 KB |
testcase_03 | AC | 265 ms
24,240 KB |
testcase_04 | AC | 206 ms
22,808 KB |
testcase_05 | AC | 118 ms
20,892 KB |
testcase_06 | AC | 205 ms
23,084 KB |
testcase_07 | AC | 194 ms
21,256 KB |
testcase_08 | AC | 38 ms
19,060 KB |
testcase_09 | AC | 232 ms
23,592 KB |
testcase_10 | AC | 79 ms
20,424 KB |
testcase_11 | AC | 77 ms
20,988 KB |
testcase_12 | AC | 159 ms
22,460 KB |
testcase_13 | AC | 300 ms
24,876 KB |
testcase_14 | AC | 154 ms
22,036 KB |
testcase_15 | AC | 228 ms
23,420 KB |
testcase_16 | AC | 369 ms
25,792 KB |
testcase_17 | AC | 125 ms
20,668 KB |
testcase_18 | AC | 235 ms
22,528 KB |
testcase_19 | AC | 106 ms
21,384 KB |
testcase_20 | AC | 329 ms
25,312 KB |
testcase_21 | AC | 61 ms
19,248 KB |
testcase_22 | AC | 424 ms
26,572 KB |
testcase_23 | AC | 452 ms
26,588 KB |
testcase_24 | AC | 420 ms
26,588 KB |
testcase_25 | AC | 426 ms
26,612 KB |
testcase_26 | AC | 436 ms
26,632 KB |
testcase_27 | AC | 433 ms
26,624 KB |
testcase_28 | AC | 443 ms
26,520 KB |
testcase_29 | AC | 400 ms
26,500 KB |
testcase_30 | AC | 404 ms
26,556 KB |
testcase_31 | AC | 417 ms
26,564 KB |
testcase_32 | AC | 423 ms
26,560 KB |
testcase_33 | AC | 413 ms
26,652 KB |
testcase_34 | AC | 422 ms
26,472 KB |
testcase_35 | AC | 423 ms
26,636 KB |
testcase_36 | AC | 405 ms
26,612 KB |
testcase_37 | AC | 417 ms
26,604 KB |
testcase_38 | AC | 441 ms
26,464 KB |
testcase_39 | AC | 431 ms
26,612 KB |
testcase_40 | AC | 418 ms
26,536 KB |
testcase_41 | AC | 420 ms
26,560 KB |
testcase_42 | AC | 311 ms
24,036 KB |
testcase_43 | AC | 309 ms
24,076 KB |
testcase_44 | AC | 311 ms
23,924 KB |
testcase_45 | AC | 325 ms
23,936 KB |
testcase_46 | AC | 314 ms
24,116 KB |
testcase_47 | AC | 236 ms
22,004 KB |
testcase_48 | AC | 240 ms
21,856 KB |
testcase_49 | AC | 233 ms
21,992 KB |
testcase_50 | AC | 231 ms
21,824 KB |
testcase_51 | AC | 234 ms
21,808 KB |
testcase_52 | AC | 32 ms
19,948 KB |
testcase_53 | AC | 31 ms
19,820 KB |
testcase_54 | AC | 32 ms
19,820 KB |
testcase_55 | AC | 86 ms
18,976 KB |
testcase_56 | AC | 85 ms
18,908 KB |
testcase_57 | AC | 87 ms
18,952 KB |
testcase_58 | AC | 31 ms
19,688 KB |
testcase_59 | AC | 462 ms
28,128 KB |
testcase_60 | AC | 28 ms
18,820 KB |
testcase_61 | AC | 84 ms
18,860 KB |
testcase_62 | AC | 19 ms
19,092 KB |
testcase_63 | AC | 75 ms
18,752 KB |
testcase_64 | AC | 77 ms
18,904 KB |
testcase_65 | AC | 114 ms
18,900 KB |
testcase_66 | AC | 86 ms
18,884 KB |
testcase_67 | AC | 44 ms
18,836 KB |
testcase_68 | AC | 36 ms
18,872 KB |
testcase_69 | AC | 41 ms
18,900 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll,ll>; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector<x>, greater<x> #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;} constexpr ll INFLL = (1LL <<62); constexpr int INF = (1<<30); int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; const ll p = 1e9+7, q = 1e9+9; const ll a = 10000019, b = 99999989; vector<ll> hp(1e6+1), hq(1e6+1), k(26); rep(i,26) k[i] = rand(); hp[0] = hq[0] = 1; rep(i,1e6) hp[i+1] = hp[i] * a % p, hq[i+1] = hq[i] * b % q; set<ll> se; rep(i,n){ string s; cin >> s; int m = s.size(); ll resp = 0, resq = 0; rep(j,m){ resp = (resp + k[s[j]-'a'] * hp[m-j]) % p; resq = (resq + k[s[j]-'a'] * hq[m-j]) % q; } bool ans = se.count(resp * resq); rep(j,m-1){ ll y = resp - k[s[j]-'a'] * hp[m-j] - k[s[j+1]-'a'] * hp[m-(j+1)] + k[s[j]-'a'] * hp[m-(j+1)] + k[s[j+1]-'a'] * hp[m-j]; ll z = resq - k[s[j]-'a'] * hq[m-j] - k[s[j+1]-'a'] * hq[m-(j+1)] + k[s[j]-'a'] * hq[m-(j+1)] + k[s[j+1]-'a'] * hq[m-j]; y = (y % p + p) % p; z = (z % q + q) % q; ans = ans + se.count(y*z); } se.insert(resp * resq); cout << (ans?"Yes\n":"No\n"); } return 0; }