1 条题解
-
0
参考答案:
#include<iostream> #include<string> using namespace std; const int N = 100010; typedef unsigned long long ULL; ULL h[N], q[N], p = 131; ULL get(int l, int r) { return h[r] - h[l - 1] * q[r - l + 1]; } int main() { int n, m; string s; cin >> n >> m; cin >> s; q[0] = 1; for (int i = 1; i <= n; ++i) { h[i] = h[i - 1] * p + s[i - 1]; q[i] = q[i - 1] * p; } while (m--) { int l1, r1, l2, r2; cin >> l1 >> r1 >> l2 >> r2; if (get(l1, r1) == get(l2, r2)) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
- 1
信息
- ID
- 87
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 2
- 已通过
- 2
- 上传者