結果

問題 No.469 区間加算と一致検索の問題
コンテスト
ユーザー vjudge1
提出日時 2026-05-18 10:23:32
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,364 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,944 ms
コンパイル使用メモリ 190,372 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-18 10:23:48
合計ジャッジ時間 5,345 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 1 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
//#include<bits/extc++.h>
  
#ifdef LOCAL
#define sc cerr
#else
#define sc if(0)cerr
//#pragma optimized("O2")
#endif
  
#define qlog(x) {sc<<#x<<" = "<<(x)<<"\n";}
#define rep(i,l,r) for(int i=(l);i<=(r);i++) 
#define irep(i,r,l) for(int i=(r);i>=(l);i--) 
#define qloga(a,l,r) {sc<<#a<<": "; rep(I,(l),(r)){sc<<a[I]<<" ";}sc<<"\n";}
#define qlogSTL(a) {sc<<#a<<": "; for(const auto &I:(a)){sc<<I<<" ";}sc<<"\n";}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
 
int n,Q;
 
constexpr int N=1e6+10;
ull a[N],b[N];
void build(){
    static mt19937_64 rnd(20260514);
    rep(i,1,n)a[i]=rnd();
    rep(i,1,n)b[i]=rnd();
}
 
int g=0;
ull cur1=0, cur2=0;
i128 cur=-1;
map<i128,int> mp;
void modify(int l,int r,ull k){
    cur1+=k*(a[r]-a[l-1]);
    cur2+=k*(b[r]-b[l-1]);
    cur=(((i128)cur1)<<64)|((i128)cur2);
    if(!mp.count(cur))mp[cur]=g;
}
ll quest(){
    return mp[cur];
}
 
signed main(){
    freopen("seq.in","r",stdin);
    freopen("seq.out","w",stdout);
    ios::sync_with_stdio(0); cin.tie(0);
 
    cin>>n>>Q;
    build();
    modify(1,1,0);
    while(Q--){
        g++;
        char opt; cin>>opt;
        if(opt=='!'){
            int l,r,k;
            cin>>l>>r>>k;
            l++;
            modify(l,r,k);
        }else{
            cout<<quest()<<"\n";
        }
    }
}
0