結果
| 問題 |
No.469 区間加算と一致検索の問題
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-12-19 00:25:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 135 ms / 5,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 1,860 ms |
| コンパイル使用メモリ | 165,392 KB |
| 実行使用メモリ | 24,832 KB |
| 最終ジャッジ日時 | 2024-12-21 16:40:03 |
| 合計ジャッジ時間 | 6,256 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d%d",&n,&q);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%s",buf);
| ~~~~~^~~~~~~~~~
main.cpp:42:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
42 | scanf("%d%d%d",&l,&r,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}
rickytheta