結果
問題 | No.469 区間加算と一致検索の問題 |
ユーザー | uenoku |
提出日時 | 2017-02-10 10:56:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,752 bytes |
コンパイル時間 | 1,013 ms |
コンパイル使用メモリ | 89,044 KB |
実行使用メモリ | 14,768 KB |
最終ジャッジ日時 | 2023-08-27 05:18:20 |
合計ジャッジ時間 | 17,607 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 15 ms
4,380 KB |
testcase_04 | AC | 19 ms
4,380 KB |
testcase_05 | AC | 22 ms
4,380 KB |
testcase_06 | AC | 25 ms
4,384 KB |
testcase_07 | AC | 27 ms
4,380 KB |
testcase_08 | AC | 30 ms
4,404 KB |
testcase_09 | AC | 13 ms
4,380 KB |
testcase_10 | AC | 22 ms
4,380 KB |
testcase_11 | AC | 9 ms
4,380 KB |
testcase_12 | AC | 32 ms
4,560 KB |
testcase_13 | AC | 19 ms
4,380 KB |
testcase_14 | AC | 6 ms
4,376 KB |
testcase_15 | AC | 10 ms
4,380 KB |
testcase_16 | AC | 27 ms
4,380 KB |
testcase_17 | AC | 24 ms
4,380 KB |
testcase_18 | AC | 26 ms
4,376 KB |
testcase_19 | AC | 5 ms
4,376 KB |
testcase_20 | AC | 30 ms
4,380 KB |
testcase_21 | AC | 8 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 224 ms
9,000 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 221 ms
8,948 KB |
testcase_27 | AC | 224 ms
8,944 KB |
testcase_28 | AC | 220 ms
9,160 KB |
testcase_29 | AC | 219 ms
9,184 KB |
testcase_30 | AC | 221 ms
9,068 KB |
testcase_31 | WA | - |
testcase_32 | AC | 221 ms
9,160 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 534 ms
14,568 KB |
testcase_36 | WA | - |
testcase_37 | AC | 533 ms
14,612 KB |
testcase_38 | AC | 497 ms
11,712 KB |
testcase_39 | AC | 500 ms
11,976 KB |
testcase_40 | WA | - |
testcase_41 | AC | 501 ms
11,780 KB |
testcase_42 | AC | 508 ms
11,800 KB |
testcase_43 | AC | 503 ms
11,952 KB |
testcase_44 | AC | 519 ms
11,788 KB |
testcase_45 | AC | 496 ms
11,824 KB |
testcase_46 | AC | 503 ms
11,848 KB |
testcase_47 | WA | - |
testcase_48 | AC | 2 ms
4,380 KB |
testcase_49 | AC | 1 ms
4,376 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
ソースコード
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; using lli = long long int; lli base1 = 12341; lli base2 = 56585; lli mod = 1e9 + 7; lli powm(lli p, lli n) { lli ans = 1; while (n) { if (n & 1) { ans = (ans * p) % mod; } p = (p * p) % mod; n /= 2; } return ans; } int main() { lli n, q; cin >> n >> q; lli l, r, x; string s; lli h1 = 0, h2 = 0; map<lli, int> g1, g2; rep(i, q) { cin >> s; if (s == "!") { cin >> l >> r >> x; h1 = (h1 + x * (powm(base1, r) - powm(base1, l) + mod) % mod * powm(base1 - 1, mod - 2) + mod * mod) % mod; h2 = (h2 + x * (powm(base2, r) - powm(base2, l) + mod) % mod * powm(base2 - 1, mod - 2) + mod * mod) % mod; if (g1[h1] == 0 && g2[h2] == 0) { g1[h1] = i + 1; g2[h2] = i + 1; } else if ( g1[h1] != 0 && g2[h2] != 0 && g1[h1] != g2[h2]) { g1[h1] = i + 1; g2[h2] = i + 1; } } else { //[l..r)にhash if (h1 == 0 && h2 == 0) { cout << 0 << endl; } else if (g1[h1] == 0 || g2[h2] == 0) { cout << i + 1 << endl; } else if (g1[h1] && g2[h2] && g1[h1] == g2[h2]) { cout << g1[h1] << endl; } else { cout << min(g1[h1], g2[h2]) << endl; } } //cout << i << ' ' << h1 << ' ' << h2 << endl; } };