結果

問題 No.469 区間加算と一致検索の問題
ユーザー rickythetarickytheta
提出日時 2016-12-19 00:25:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 998 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 150,720 KB
実行使用メモリ 27,684 KB
最終ジャッジ日時 2023-08-23 13:18:20
合計ジャッジ時間 6,279 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,544 KB
testcase_01 AC 2 ms
5,568 KB
testcase_02 AC 4 ms
8,428 KB
testcase_03 AC 5 ms
5,840 KB
testcase_04 AC 5 ms
6,116 KB
testcase_05 AC 6 ms
5,916 KB
testcase_06 AC 6 ms
6,004 KB
testcase_07 AC 7 ms
6,004 KB
testcase_08 AC 8 ms
6,008 KB
testcase_09 AC 4 ms
5,856 KB
testcase_10 AC 6 ms
5,900 KB
testcase_11 AC 3 ms
5,892 KB
testcase_12 AC 8 ms
6,340 KB
testcase_13 AC 6 ms
6,136 KB
testcase_14 AC 3 ms
5,900 KB
testcase_15 AC 4 ms
5,632 KB
testcase_16 AC 7 ms
6,052 KB
testcase_17 AC 6 ms
6,064 KB
testcase_18 AC 7 ms
6,060 KB
testcase_19 AC 3 ms
5,676 KB
testcase_20 AC 7 ms
6,072 KB
testcase_21 AC 3 ms
5,684 KB
testcase_22 AC 2 ms
5,536 KB
testcase_23 AC 41 ms
8,424 KB
testcase_24 AC 40 ms
8,480 KB
testcase_25 AC 40 ms
8,508 KB
testcase_26 AC 40 ms
8,424 KB
testcase_27 AC 40 ms
8,452 KB
testcase_28 AC 40 ms
8,388 KB
testcase_29 AC 40 ms
8,388 KB
testcase_30 AC 39 ms
8,468 KB
testcase_31 AC 40 ms
8,448 KB
testcase_32 AC 40 ms
8,648 KB
testcase_33 AC 116 ms
27,684 KB
testcase_34 AC 118 ms
27,660 KB
testcase_35 AC 121 ms
27,468 KB
testcase_36 AC 116 ms
27,520 KB
testcase_37 AC 115 ms
27,472 KB
testcase_38 AC 100 ms
26,128 KB
testcase_39 AC 100 ms
26,240 KB
testcase_40 AC 99 ms
26,100 KB
testcase_41 AC 98 ms
26,104 KB
testcase_42 AC 99 ms
26,040 KB
testcase_43 AC 99 ms
26,196 KB
testcase_44 AC 100 ms
26,152 KB
testcase_45 AC 99 ms
26,120 KB
testcase_46 AC 103 ms
26,116 KB
testcase_47 AC 100 ms
26,128 KB
testcase_48 AC 2 ms
5,580 KB
testcase_49 AC 2 ms
5,500 KB
testcase_50 AC 98 ms
26,128 KB
testcase_51 AC 103 ms
26,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
// typedef __uint128_t ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define CHMIN(a,b) a=min((a),(b))

const ll MOD = 281474976710597ll;
const ll BASE = 10009ll;

// const ll MOD = 9223372036854775783ll;
// const ll BASE = 1000000007ll;
// const ll C = 12525211ll;

int n,q;
char buf[25];
ll bpow[1252525];
ll bsum[1252525];

int main(){
  scanf("%d%d",&n,&q);
  
  bpow[0] = 1;
  REP(i,n)bpow[i+1] = BASE*bpow[i]%MOD;
  bsum[0] = 0;
  REP(i,n)bsum[i+1] = (bsum[i]+bpow[i])%MOD;

  map<ll,int> M;
  ll cur = 0;
  M[cur] = 0;
  REP(i,q){
    scanf("%s",buf);
    if(buf[0]=='!'){
      int l,r,k;
      scanf("%d%d%d",&l,&r,&k);
      ll v = (MOD+(bsum[r]-bsum[l]+MOD)%MOD*k%MOD)%MOD;
      cur = (cur + v)%MOD;
      if(!M.count(cur)){
        M[cur] = i+1;
      }
    }else{
      // query
      printf("%d\n",M[cur]);
    }
  }
  return 0;
}
0