Submission #752180

# Submission time Handle Problem Language Result Execution time Memory
752180 2023-06-02T12:37:20 Z Sam_a17 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
99 ms 10876 KB
#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;

void Send(int a);
 
void Anna(int N, std::vector<char> S) {
  Send(0);
  for(int i = 0; i < N; i++) {
    if(S[i] == 'X') {
      Send(0);
    } else if(S[i] == 'Y') {
      Send(1);
      Send(0);
    } else {
      Send(1);
      Send(1);
      Send(0);
    }
  }
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;

void Remove(int d);

void Bruno(int N, int L, std::vector<int> A) {
  vector<int> a;
  for(int i = 0; i < L - 1; i++) {
    assert(A[i] == 0);

    int j = i + 1, cnt = 0;
    while(j < L && A[j] == 1) {
      j++, cnt++;
    }
    
    if(cnt == 0) {
      a.push_back(0);
    } else if(cnt == 1) {
      a.push_back(1);
    } else {
      a.push_back(2);
    }

    i = j - 1;
  }

  set<int> st[3];

  auto dll = [&](int l, int r)-> void {
    for(int i = 0; i < 3; i++) {
      auto it = st[i].lower_bound(l);
      vector<int> to_del;
      while(it != st[i].end() && *it < r) {
        to_del.push_back(*it);
        it = next(it);
      }

      for(auto j: to_del) {
        Remove(j);
        st[i].erase(j);
      }
    }
  };


  for (int i = 0; i < N; i++) {
    int ok = 0;
    if(a[i] == 2) {
      if(!st[1].empty() && !st[0].empty()) {
        auto itr = *st[1].rbegin();
        auto itl = *st[0].begin();

        if(itl < itr) {
          dll(itr + 1, i);
          itl = *st[0].rbegin();
          dll(itl + 1, itr);

          //
          st[1].erase(prev(st[1].end()));
          Remove(itr);
          ok = 1;
        }
      }
    }

    st[a[i]].insert(i);
  }

  for(int i = 0; i < 3; i++) {
    for(auto j: st[i]) {
      Remove(j);
    }
  }
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:48:9: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   48 |     int ok = 0;
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 512 KB Output is correct
2 Correct 0 ms 616 KB Output is correct
3 Correct 0 ms 520 KB Output is correct
4 Correct 1 ms 524 KB Output is correct
5 Incorrect 0 ms 512 KB Wrong Answer [6]
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 97 ms 10876 KB Partially correct
2 Incorrect 99 ms 10804 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -