Submission #60043712
Source Code Expand
Copy
#include<bits/stdc++.h>#define int long long#define For(i, a, b) for(int i = (a); i <= (b); i++)#define Rof(i, a, b) for(int i = (a); i >= (b); i--)#define deb(x) cerr << #x"=" << x << '\n'using namespace std;const int N = 5e5 + 5;int n, ans, lst[N];string s;void Solve(){cin >> n >> s;s = ' ' + s;For(i, 1, n){if(s[i] != s[i - 1]) lst[i] = i;else lst[i] = lst[i - 1];if(s[i] == '/') ans = max(ans, 1ll);}For(i, 1, n) if(s[i] == '2'){int p1 = lst[i] - 1;if(p1 <= 1 || s[p1] != '/') continue;int p2 = lst[p1 - 1];
#include<bits/stdc++.h> #define int long long #define For(i, a, b) for(int i = (a); i <= (b); i++) #define Rof(i, a, b) for(int i = (a); i >= (b); i--) #define deb(x) cerr << #x"=" << x << '\n' using namespace std; const int N = 5e5 + 5; int n, ans, lst[N]; string s; void Solve(){ cin >> n >> s; s = ' ' + s; For(i, 1, n){ if(s[i] != s[i - 1]) lst[i] = i; else lst[i] = lst[i - 1]; if(s[i] == '/') ans = max(ans, 1ll); } For(i, 1, n) if(s[i] == '2'){ int p1 = lst[i] - 1; if(p1 <= 1 || s[p1] != '/') continue; int p2 = lst[p1 - 1]; if(s[p1 - 1] != '1') continue; ans = max(ans, 1 + 2 * min(i - p1, p1 - 1 - p2 + 1)); } cout << ans << '\n'; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; //cin >> T; while(T--) Solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 11/22 Substring |
User | Anyees |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 822 Byte |
Status | AC |
Exec Time | 4 ms |
Memory | 5204 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 02_corner_00.txt, 02_corner_01.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3416 KB |
00_sample_01.txt | AC | 1 ms | 3380 KB |
00_sample_02.txt | AC | 1 ms | 3476 KB |
01_random_00.txt | AC | 4 ms | 5156 KB |
01_random_01.txt | AC | 4 ms | 5160 KB |
01_random_02.txt | AC | 4 ms | 5156 KB |
01_random_03.txt | AC | 4 ms | 5008 KB |
01_random_04.txt | AC | 4 ms | 5204 KB |
01_random_05.txt | AC | 4 ms | 5096 KB |
01_random_06.txt | AC | 2 ms | 5084 KB |
01_random_07.txt | AC | 4 ms | 5100 KB |
01_random_08.txt | AC | 4 ms | 5156 KB |
01_random_09.txt | AC | 3 ms | 5012 KB |
01_random_10.txt | AC | 3 ms | 5156 KB |
01_random_11.txt | AC | 4 ms | 5096 KB |
01_random_12.txt | AC | 3 ms | 5140 KB |
01_random_13.txt | AC | 3 ms | 5160 KB |
01_random_14.txt | AC | 4 ms | 5096 KB |
01_random_15.txt | AC | 2 ms | 5152 KB |
01_random_16.txt | AC | 3 ms | 5160 KB |
01_random_17.txt | AC | 2 ms | 5104 KB |
01_random_18.txt | AC | 3 ms | 5168 KB |
01_random_19.txt | AC | 3 ms | 5084 KB |
02_corner_00.txt | AC | 2 ms | 5008 KB |
02_corner_01.txt | AC | 1 ms | 3460 KB |