結果
問題 | No.469 区間加算と一致検索の問題 |
ユーザー | はまやんはまやん |
提出日時 | 2017-03-15 18:54:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
OLE
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 175,056 KB |
実行使用メモリ | 11,236 KB |
最終ジャッジ日時 | 2024-07-04 01:21:34 |
合計ジャッジ時間 | 15,912 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | OLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:64, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: In member function 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int; _T2 = int]', inlined from 'void pre()' at main.cpp:15:110: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_pair.h:584:15: warning: iteration 1010099 invokes undefined behavior [-Waggressive-loop-optimizations] 584 | first = std::forward<first_type>(__p.first); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp: In function 'void pre()': main.cpp:3:33: note: within this loop 3 | #define rep(i,a,b) for(int i=a;i<b;i++) | ^ main.cpp:15:9: note: in expansion of macro 'rep' 15 | rep(i, 1, 1010101) imos[i + 1] = {(imos[i].first * add0 + add0) % mo0, (imos[i].second * add1 + add1) % mo1 }; |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) typedef long long ll; static const ll mo0 = 1000000007, mo1 = 1000000009; static const ll add0 = 10009, add1 = 10007; typedef pair<int, int> Hash; int N, Q; //----------------------------------------------------------------- Hash imos[1010101]; void pre() { imos[0] = { 0, 0 }; rep(i, 1, 1010101) imos[i + 1] = {(imos[i].first * add0 + add0) % mo0, (imos[i].second * add1 + add1) % mo1 }; } Hash calc(Hash h, int L, int R, int K) { Hash one = imos[R]; if (0 < L) one = { one.first - imos[L].first, one.second - imos[L].second }; one.first = (one.first + mo0) % mo0; one.second = (one.second + mo1) % mo1; return{ (h.first + one.first * ((K + mo0) % mo0)) % mo0, (h.second + one.second * ((K + mo1) % mo1)) % mo1 }; } //----------------------------------------------------------------- map<Hash, int> ans; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> Q; pre(); Hash h = { 0, 0 }; ans[h] = 0; rep(q, 1, Q + 1) { char t; cin >> t; if (t == '!') { int L, R, K; cin >> L >> R >> K; h = calc(h, L, R, K); if (ans.count(h) == 0) ans[h] = q; } else { printf("%d\n", ans[h]); } } }