結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー auauaauaua
提出日時 2021-10-29 22:23:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,279 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 169,992 KB
実行使用メモリ 51,840 KB
最終ジャッジ日時 2024-04-16 15:12:54
合計ジャッジ時間 5,124 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 29 ms
5,376 KB
testcase_38 AC 29 ms
5,376 KB
testcase_39 AC 28 ms
5,376 KB
testcase_40 AC 29 ms
5,376 KB
testcase_41 AC 28 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 62 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=200010;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;



void solve(){
    string x,y;cin>>x>>y;
    ll a=x.size(),b=y.size();
    vector<vector<ll> >cntx(a,vector<ll>(26)),cnty(b,vector<ll>(26));
    rep(i,a){
        if(i){
            rep(j,26){
                cntx[i][j]=cntx[i-1][j];
            }
        }
        cntx[i][x[i]-'a']++;
    }
    rep(i,b){
        if(i){
            rep(j,26){
                cnty[i][j]=cnty[i-1][j];
            }
        }
        cnty[i][y[i]-'a']++;
    }
    ll q;cin>>q;
    while(q--){
        ll l,r;
        cin>>l>>r;
        char c;cin>>c;
        ll z=c-'a';
        ll w=(l-1)/(a+b);
        ll e=(l-1)%(a+b);
        ll t=r/(a+b);
        ll u=r%(a+b);
        ll m=cntx[a-1][z]+cnty[b-1][z];
        ll sum1=w*m,sum2=m*t;
        if(e>=a){
            sum1+=cntx[a-1][z];
            bool f=0;
            ll now=w+1;
            for(int j=32;j>=1;j--){
                if((1LL<<j)>now)continue;
                if(now==(1LL<<j)){
                    f=0;
                    break;
                }
                f^=1;
                now=(1LL<<j)*2LL-now;
            }
            if(!f){
                if(e>a){
                    sum1+=cnty[e-a-1][z];
                }
            }else{
                if(e>a){
                    sum1+=cnty[b-1][z]-cnty[b-1-(e-a)][z];
                }
            }
        }else{
            if((w+1)%2==0){
                if(e){
                    sum1+=cntx[a-1][z]-cntx[a-1-e][z];
                }
            }else{
                if(e){
                    sum1+=cntx[e-1][z];
                }
            }
        }
        swap(e,u),swap(t,w);
        if(e>=a){
            sum2+=cntx[a-1][z];
            bool f=0;
            ll now=w+1;
            for(int j=32;j>=0;j--){
                if((1LL<<j)>now)continue;
                if(now==(1LL<<j)){
                    break;
                }
                f^=1;
                now=(1LL<<j)*2LL-now;
            }
            if(!f){
                if(e>a){
                    sum2+=cnty[e-a-1][z];
                }
            }else{
                if(e>a){
                    sum2+=cnty[b-1][z]-cnty[b-1-(e-a)][z];
                }
            }
        }else{
            if((w+1)%2==0){
                if(e){
                    sum2+=cntx[a-1][z]-cntx[a-1-e][z];
                }
            }else{
                if(e){
                    sum2+=cntx[e-1][z];
                }
            }
        }
        cout<<sum2-sum1<<endl;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0