Submission #60054918
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <map> #include <set> #include <atcoder/all> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, l, r) for (int i = l; i <= r; i++) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using ll = long long; using VI = vector<int>; using VL = vector<ll>; using VVI = vector<VI>; using VVL = vector<VL>; int calc(VI a) { int n = a.size(); // cout << n << endl; // REP(i,n) cout << a[i] << " "; // cout << endl; int ans = 0; map<int, int> cnt; int r = 0; REP(l,n) { if (r < l) r = l; while (r < n && a[r] != -1 && cnt[a[r]] == 0) { cnt[a[r]]++; r++; } // cout << l << " " << r << endl; chmax(ans, r - l); if (a[l] != -1) { cnt[a[l]]--; } } return ans; } int main() { int n; cin >> n; VI a(n); REP(i,n) cin >> a[i]; int ans = 0; VI b, c; REP(i,n/2) { int j1 = 2 * i; int j2 = 2 * i + 1; if (a[j1] == a[j2]) { b.push_back(a[j1]); } else { b.push_back(-1); } j1++; j2++; if (j2 >= n) continue; if (a[j1] == a[j2]) { c.push_back(a[j1]); } else { c.push_back(-1); } } ans = max(calc(b), calc(c)); cout << 2 * ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - 1122 Substring |
User | TangentDay |
Language | C++ 20 (gcc 12.2) |
Score | 425 |
Code Size | 1532 Byte |
Status | AC |
Exec Time | 89 ms |
Memory | 10344 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 425 / 425 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt, example_02.txt |
All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3596 KiB |
example_01.txt | AC | 1 ms | 3492 KiB |
example_02.txt | AC | 1 ms | 3492 KiB |
hand_00.txt | AC | 87 ms | 10264 KiB |
hand_01.txt | AC | 36 ms | 5488 KiB |
hand_02.txt | AC | 87 ms | 9688 KiB |
hand_03.txt | AC | 78 ms | 7892 KiB |
hand_04.txt | AC | 34 ms | 5492 KiB |
hand_05.txt | AC | 1 ms | 3460 KiB |
random_00.txt | AC | 39 ms | 5500 KiB |
random_01.txt | AC | 40 ms | 5532 KiB |
random_02.txt | AC | 42 ms | 5420 KiB |
random_03.txt | AC | 46 ms | 5460 KiB |
random_04.txt | AC | 57 ms | 5556 KiB |
random_05.txt | AC | 56 ms | 5448 KiB |
random_06.txt | AC | 67 ms | 6252 KiB |
random_07.txt | AC | 64 ms | 6336 KiB |
random_08.txt | AC | 73 ms | 7620 KiB |
random_09.txt | AC | 72 ms | 7660 KiB |
random_10.txt | AC | 37 ms | 5548 KiB |
random_11.txt | AC | 41 ms | 5564 KiB |
random_12.txt | AC | 41 ms | 5536 KiB |
random_13.txt | AC | 46 ms | 5444 KiB |
random_14.txt | AC | 56 ms | 5480 KiB |
random_15.txt | AC | 56 ms | 5452 KiB |
random_16.txt | AC | 67 ms | 6572 KiB |
random_17.txt | AC | 67 ms | 6552 KiB |
random_18.txt | AC | 81 ms | 9196 KiB |
random_19.txt | AC | 81 ms | 9352 KiB |
random_20.txt | AC | 64 ms | 7888 KiB |
random_21.txt | AC | 86 ms | 10268 KiB |
random_22.txt | AC | 75 ms | 9548 KiB |
random_23.txt | AC | 85 ms | 9760 KiB |
random_24.txt | AC | 89 ms | 10344 KiB |
random_25.txt | AC | 87 ms | 9908 KiB |
random_26.txt | AC | 61 ms | 7076 KiB |
random_27.txt | AC | 71 ms | 7652 KiB |
random_28.txt | AC | 36 ms | 5572 KiB |
random_29.txt | AC | 36 ms | 5516 KiB |