Submission #18281891


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll N; cin >> N;
string S; cin >> S;
stack<char> st;
for (ll i = 0; i < N; i++) {
if (st.size() >= 2 && S[i] == 'x') {
char c1 = st.top(); st.pop();
char c0 = st.top();
if (c0 == 'f' && c1 == 'o') {
st.pop();
} else {
st.push(c1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N; cin >> N;
  string S; cin >> S;

  stack<char> st;

  for (ll i = 0; i < N; i++) {
    if (st.size() >= 2 && S[i] == 'x') {
      char c1 = st.top(); st.pop();
      char c0 = st.top();
      if (c0 == 'f' && c1 == 'o') {
        st.pop();
      } else {
        st.push(c1);
        st.push(S[i]);
      }
    } else {
      st.push(S[i]);
    }
  }
  ll ans = st.size();
  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task B - Abbreviate Fox
User nakaken88
Language C++ (GCC 9.2.1)
Score 400
Code Size 575 Byte
Status AC
Exec Time 9 ms
Memory 3788 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 26
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3512 KB
hand_02.txt AC 2 ms 3572 KB
hand_03.txt AC 4 ms 3676 KB
random_01.txt AC 4 ms 3588 KB
random_02.txt AC 9 ms 3780 KB
random_03.txt AC 3 ms 3632 KB
random_04.txt AC 5 ms 3724 KB
random_05.txt AC 7 ms 3748 KB
random_06.txt AC 5 ms 3652 KB
random_07.txt AC 4 ms 3744 KB
random_08.txt AC 2 ms 3620 KB
random_09.txt AC 5 ms 3716 KB
random_10.txt AC 6 ms 3780 KB
random_11.txt AC 5 ms 3704 KB
random_12.txt AC 3 ms 3592 KB
random_13.txt AC 6 ms 3744 KB
random_14.txt AC 3 ms 3596 KB
random_15.txt AC 9 ms 3656 KB
random_16.txt AC 3 ms 3560 KB
random_17.txt AC 5 ms 3788 KB
random_18.txt AC 2 ms 3520 KB
random_19.txt AC 5 ms 3724 KB
random_20.txt AC 4 ms 3712 KB
sample_01.txt AC 2 ms 3604 KB
sample_02.txt AC 2 ms 3564 KB
sample_03.txt AC 2 ms 3552 KB


2025-04-05 (Sat)
20:46:11 +00:00