Please sign in first.
Submission #74685087
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair<ull, ull> puu;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++)
cin >> A[i];
const int MAX_LEN = 55;
const ull B1 = 911382323;
const ull B2 = 972663749;
set<puu> found;
for (int i = 0; i < N; i++) {
ull h1 = 0, h2 = 0;
int val = 0, len = 0; // 当前块
for (int j = i; j < min(i + MAX_LEN, N); j++) {
h1 = h1 * B1 + A[j] + 1;
h2 = h2 * B2 + A[j] + 1;
if (len == 0) {
// 第一个元素
val = A[j];
len = 1;
} else if (val == A[j]) {
// 同一块
len++;
} else {
// 不同值,检查前一块
if (len != val)
break; // 前一块不完整,无法形成221
// 新块
val = A[j];
len = 1;
}
if (len > val)
break; // 当前块过长
// 检查是否形成完整221序列
if (len == val) {
found.insert({h1, h2});
}
}
}
cout << found.size() << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | G - 221 Substring |
| User | Eason0709 |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 1105 Byte |
| Status | WA |
| Exec Time | > 2000 ms |
| Memory | 109888 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 600 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3596 KiB |
| 00-sample-02.txt | AC | 1 ms | 3560 KiB |
| 01-01.txt | AC | 1 ms | 3556 KiB |
| 01-02.txt | AC | 1 ms | 3592 KiB |
| 01-03.txt | AC | 1 ms | 3528 KiB |
| 01-04.txt | WA | 1 ms | 3548 KiB |
| 01-05.txt | WA | 2 ms | 3668 KiB |
| 01-06.txt | WA | 1 ms | 3756 KiB |
| 01-07.txt | WA | 1 ms | 3684 KiB |
| 01-08.txt | WA | 1 ms | 3556 KiB |
| 01-09.txt | WA | 1 ms | 3560 KiB |
| 01-10.txt | WA | 1 ms | 3528 KiB |
| 01-11.txt | WA | 1 ms | 3608 KiB |
| 01-12.txt | WA | 1 ms | 3720 KiB |
| 01-13.txt | WA | 1 ms | 3760 KiB |
| 01-14.txt | WA | 1 ms | 3724 KiB |
| 01-15.txt | WA | 1 ms | 3628 KiB |
| 01-16.txt | WA | 1 ms | 3764 KiB |
| 01-17.txt | WA | 1 ms | 3720 KiB |
| 01-18.txt | WA | 1 ms | 3720 KiB |
| 01-19.txt | WA | 1 ms | 3608 KiB |
| 01-20.txt | AC | 15 ms | 5244 KiB |
| 01-21.txt | AC | 19 ms | 5384 KiB |
| 01-22.txt | AC | 18 ms | 5348 KiB |
| 01-23.txt | WA | 143 ms | 5300 KiB |
| 01-24.txt | TLE | > 2000 ms | 109888 KiB |
| 01-25.txt | TLE | > 2000 ms | 81748 KiB |
| 01-26.txt | WA | 549 ms | 42224 KiB |
| 01-27.txt | WA | 142 ms | 5396 KiB |
| 01-28.txt | WA | 143 ms | 5360 KiB |
| 01-29.txt | WA | 143 ms | 5384 KiB |
| 01-30.txt | WA | 96 ms | 5448 KiB |
| 01-31.txt | TLE | > 2000 ms | 108356 KiB |
| 01-32.txt | TLE | > 2000 ms | 107392 KiB |
| 01-33.txt | TLE | > 2000 ms | 105836 KiB |
| 01-34.txt | TLE | > 2000 ms | 98756 KiB |
| 01-35.txt | TLE | > 2000 ms | 65220 KiB |
| 01-36.txt | TLE | > 2000 ms | 71924 KiB |
| 01-37.txt | TLE | > 2000 ms | 72048 KiB |
| 01-38.txt | WA | 1766 ms | 66184 KiB |
| 01-39.txt | WA | 561 ms | 42152 KiB |
| 01-40.txt | WA | 565 ms | 42160 KiB |
| 01-41.txt | WA | 575 ms | 42436 KiB |
| 01-42.txt | WA | 421 ms | 35292 KiB |
| 01-43.txt | AC | 1 ms | 3560 KiB |
| 01-44.txt | AC | 1 ms | 3532 KiB |
| 01-45.txt | AC | 1 ms | 3560 KiB |
| 01-46.txt | WA | 1 ms | 3660 KiB |
| 01-47.txt | WA | 2 ms | 3720 KiB |
| 01-48.txt | AC | 1 ms | 3532 KiB |
| 01-49.txt | WA | 33 ms | 7560 KiB |
| 01-50.txt | WA | 43 ms | 7816 KiB |
| 01-51.txt | WA | 23 ms | 5780 KiB |