Submission #1331728

#TimeUsernameProblemLanguageResultExecution timeMemory
1331728nguyengiabach1201Ancient Machine (JOI21_ancient_machine)C++20
0 / 100
354 ms8244 KiB
// https://oj.uz/problem/view/JOI21_ancient_machine

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include "Anna.h"

using namespace std;
using namespace __gnu_pbds;

// #define el '\n'
// #define FNAME ""
// #define ll long long
// #define int long long
// #define ld long double

// const int MOD = 1e9 + 7;
// const ll INF = 1e18 + 7;
// const double EPS = 1e-9;

void Anna(int N, std::vector<char> S)
{
  for (int i = 0; i < N; ++i)
    if (S[i] == 'X')
      Send(0), Send(0);
    else if (S[i] == 'Y')
      Send(0), Send(1);
    else // if (S[i] == 'Z')
      Send(1), Send(0);
}
// https://oj.uz/problem/view/JOI21_ancient_machine

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include "Bruno.h"

using namespace std;
using namespace __gnu_pbds;

// #define el '\n'
// #define FNAME ""
// #define ll long long
// #define int long long
// #define ld long double

// const int MOD = 1e9 + 7;
// const ll INF = 1e18 + 7;
// const double EPS = 1e-9;

void Bruno(int N, int L, vector<int> A)
{
  string S;

  for (int i = 0; i < L; i += 2)
    if (A[i] == 0 && A[i + 1] == 0)
      S += "X";
    else if (A[i] == 0 && A[i + 1] == 1)
      S += "Y";
    else
      S += "Z";

  int firstX, lastZ;

  for (int i = 0; i < N; ++i)
  {
    if (S[i] == 'X')
    {
      firstX = i;
      break;
    }

    // Remove(i);
  }

  for (int i = N - 1; i >= 0; --i)
  {
    if (S[i] == 'Z')
    {
      lastZ = i;
      break;
    }

    // Remove(i);
  }

  bool needY = true;
  vector<int> pos = {firstX};

  for (int i = firstX + 1; i <= lastZ; ++i)
  {
    if (needY)
    {
      if (S[i] == 'Y')
        pos.push_back(i), needY = false;
    }
    else
    {
      if (S[i] == 'Z')
        pos.push_back(i), needY = true;
    }
  }

  for (char c : S)
    cerr << c << " ";
  cerr << "\n";

  cerr << firstX << " " << lastZ << "\n";
  cerr << "!!! ";
  for (int i : pos)
    cerr << i << " ";
  cerr << "\n";

  for (int i = 0; i < pos.front(); ++i)
    Remove(i), cerr << i << "\n";

  for (int i = pos.back() + 1; i < N; ++i)
    Remove(i), cerr << i << "\n";

  for (int i = 1; i < pos.size(); i += 2)
  {
    for (int j = pos[i - 1] + 1; j < pos[i]; ++j)
      Remove(j), cerr << j << "\n";

    for (int j = pos[i] + 1; j < pos[i + 1]; ++j)
      Remove(j), cerr << j << "\n";

    Remove(pos[i]), cerr << pos[i] << "\n";
    Remove(pos[i + 1]), cerr << pos[i + 1] << "\n";
  }

  Remove(firstX), cerr << firstX << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...