# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110861 | mosesmayer | Match (CEOI16_match) | C++17 | 19 ms | 11776 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mxsz = 1e5 + 5;
int n;
char S[mxsz], ans[mxsz];
int lft[mxsz][26];
void prec(){
for (int i = 1, p; i <= n; i++){
p = S[i] - 'a';
lft[i][p] = i;
if (i - 1)
for (int j = 0, x = lft[i-1][p]; j < 26; j++)
if (x && (j^p))
lft[i][j] = lft[x-1][j]; // link to before prev to be able to match prev with i
}
//for (int i = 1; i <= n; i++) for (int j = 0; j < 26; j++) cout << lft[i][j] << " \n"[j==25];
}
stack<int> st;
inline bool CHECK(){
for (int i = 1, p; i <= n; i++){
p = S[i] - 'a';
if (st.empty() || st.top() != p) st.push(p);
else st.pop();
}
return st.empty();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |