結果
| 問題 | No.469 区間加算と一致検索の問題 |
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2017-03-15 18:54:57 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
OLE
|
| 実行時間 | - |
| コード長 | 1,218 bytes |
| 記録 | |
| コンパイル時間 | 1,295 ms |
| コンパイル使用メモリ | 188,896 KB |
| 実行使用メモリ | 1,165,852 KB |
| 最終ジャッジ日時 | 2026-03-25 09:24:27 |
| 合計ジャッジ時間 | 324,040 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | OLE * 3 |
| other | TLE * 14 MLE * 30 OLE * 5 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:64,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
In member function 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)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/15.2.0_1/include/c++/15/bits/stl_pair.h:957:15: warning: iteration 1010099 invokes undefined behavior [-Waggressive-loop-optimizations]
957 | 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]);
}
}
}
はまやんはまやん