結果
問題 |
No.469 区間加算と一致検索の問題
|
ユーザー |
![]() |
提出日時 | 2016-12-20 15:23:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 759 bytes |
コンパイル時間 | 1,679 ms |
コンパイル使用メモリ | 176,900 KB |
実行使用メモリ | 43,224 KB |
最終ジャッジ日時 | 2024-12-14 11:21:45 |
合計ジャッジ時間 | 7,766 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(c) begin(c), end(c) #define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl using LL = __int128; LL s[1000010], t[1000010]; map<pair<LL,LL>, int> first; int main(){ int n, q; cin >> n >> q; s[0] = t[0] = 1; for(int i = 0; i < n; ++i) s[i+1] = s[i] * 10007; for(int i = 0; i < n; ++i) t[i+1] = t[i] * 10009; auto cur = make_pair(0, 0); for(int i = 0; i < q; ++i){ char c; cin >> c; if(c == '?'){ cout << first[cur] << '\n'; } else { int l, r, k; cin >> l >> r >> k; cur.first += (s[r] - s[l]) * k; cur.second += (t[r] - t[l]) * k; } if(!first.count(cur)) first[cur] = i + 1; } }