結果

問題 No.2102 [Cherry Alpha *] Conditional Reflection
ユーザー fumofumofunifumofumofuni
提出日時 2022-10-14 23:15:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 769 ms / 3,000 ms
コード長 2,241 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 208,036 KB
実行使用メモリ 31,180 KB
最終ジャッジ日時 2023-09-08 23:37:55
合計ジャッジ時間 35,545 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
18,448 KB
testcase_01 AC 12 ms
18,444 KB
testcase_02 AC 394 ms
24,200 KB
testcase_03 AC 458 ms
25,988 KB
testcase_04 AC 435 ms
23,968 KB
testcase_05 AC 346 ms
21,532 KB
testcase_06 AC 464 ms
24,576 KB
testcase_07 AC 298 ms
21,820 KB
testcase_08 AC 184 ms
18,852 KB
testcase_09 AC 382 ms
25,108 KB
testcase_10 AC 230 ms
20,888 KB
testcase_11 AC 156 ms
21,444 KB
testcase_12 AC 329 ms
23,912 KB
testcase_13 AC 504 ms
26,680 KB
testcase_14 AC 390 ms
23,132 KB
testcase_15 AC 514 ms
24,796 KB
testcase_16 AC 645 ms
28,028 KB
testcase_17 AC 204 ms
21,116 KB
testcase_18 AC 364 ms
23,872 KB
testcase_19 AC 260 ms
22,088 KB
testcase_20 AC 535 ms
27,244 KB
testcase_21 AC 310 ms
19,288 KB
testcase_22 AC 712 ms
28,948 KB
testcase_23 AC 715 ms
29,000 KB
testcase_24 AC 701 ms
28,988 KB
testcase_25 AC 708 ms
29,052 KB
testcase_26 AC 699 ms
29,012 KB
testcase_27 AC 712 ms
29,004 KB
testcase_28 AC 704 ms
29,020 KB
testcase_29 AC 702 ms
29,060 KB
testcase_30 AC 697 ms
28,956 KB
testcase_31 AC 693 ms
29,008 KB
testcase_32 AC 695 ms
29,128 KB
testcase_33 AC 708 ms
29,212 KB
testcase_34 AC 708 ms
29,012 KB
testcase_35 AC 751 ms
28,956 KB
testcase_36 AC 769 ms
29,044 KB
testcase_37 AC 708 ms
29,068 KB
testcase_38 AC 695 ms
29,132 KB
testcase_39 AC 700 ms
29,204 KB
testcase_40 AC 702 ms
28,948 KB
testcase_41 AC 694 ms
29,132 KB
testcase_42 AC 490 ms
25,648 KB
testcase_43 AC 491 ms
25,524 KB
testcase_44 AC 492 ms
25,696 KB
testcase_45 AC 487 ms
25,548 KB
testcase_46 AC 488 ms
25,544 KB
testcase_47 AC 371 ms
22,620 KB
testcase_48 AC 364 ms
22,548 KB
testcase_49 AC 370 ms
22,628 KB
testcase_50 AC 369 ms
22,620 KB
testcase_51 AC 359 ms
23,008 KB
testcase_52 AC 45 ms
20,652 KB
testcase_53 AC 44 ms
20,832 KB
testcase_54 AC 45 ms
20,712 KB
testcase_55 AC 114 ms
18,444 KB
testcase_56 AC 114 ms
18,540 KB
testcase_57 AC 114 ms
18,496 KB
testcase_58 AC 46 ms
20,188 KB
testcase_59 AC 723 ms
31,180 KB
testcase_60 AC 173 ms
18,460 KB
testcase_61 AC 114 ms
18,752 KB
testcase_62 AC 27 ms
19,052 KB
testcase_63 AC 174 ms
18,448 KB
testcase_64 AC 179 ms
18,764 KB
testcase_65 AC 226 ms
18,556 KB
testcase_66 AC 114 ms
18,744 KB
testcase_67 AC 333 ms
18,460 KB
testcase_68 AC 55 ms
18,848 KB
testcase_69 AC 332 ms
18,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")

#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,1,0,-1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
static const int base1 = 1007, base2 = 2009;
static const int mod1 = 1000000007, mod2 = 1000000009;
ll safemod(ll a,ll m){
    return (a%m+m)%m;
}
int main(){
    ll m=1e6+10;
    vl power1(m,1),power2(m,1);
    rep(i,m-1){
        power1[i+1]=power1[i]*base1%mod1;
        power2[i+1]=power2[i]*base2%mod2;
    }
    set<pl> st;
    ll n;cin >> n;
    while(n--){
        string s;cin >> s;
        ll p=s.size();
        pl q={0,0};
        rep(i,p){
            q.first=(q.first+power1[i]*s[i])%mod1;
            q.second=(q.second+power2[i]*s[i])%mod2;
        }
        bool ok=st.count(q);
        rep(i,p-1){
            pl f=q;
            f.first-=power1[i]*s[i];
            f.first-=power1[i+1]*s[i+1];
            f.second-=power2[i]*s[i];
            f.second-=power2[i+1]*s[i+1];
            f.first+=power1[i]*s[i+1];
            f.first+=power1[i+1]*s[i];
            f.second+=power2[i+1]*s[i];
            f.second+=power2[i]*s[i+1];
            f.first=safemod(f.first,mod1);
            f.second=safemod(f.second,mod2);
            ok|=st.count(f);
        }
        st.insert(q);
        cout << (ok? "Yes":"No") << endl;
    }

}
0