Submission #1078623

# Submission time Handle Problem Language Result Execution time Memory
1078623 2024-08-28T00:50:30 Z 8pete8 Ancient Machine (JOI21_ancient_machine) C++17
Compilation error
0 ms 0 KB
#include "Anna.h"
#include <vector>
using namespace std;
namespace {

int variable_example = 0;

}

void Anna(int N, vector<char> S){
  int found=0;
  for(auto i:S){
    if(found==0){
      if(i=='X')found=1;
      Send(found);
    }
    else{
      if(i=='Z')Send(1);
      else Send(0);
    }
  }
}

/*
10
X Y X Y Z X Y Z Y Z

trying to solve in N
if we highlight all y and do it backward it might remove a z
but not an x between -xz
and wont remove x'z'yz

x yyyyyy xz yyyy z
we have to choose one

so the 2nd x will becomne uselss and the 2nd group of y
what if we remove all useless one first
then we will be left with
xyyyz xyyz xyyz
now can we just do from left to right

highlight first x and a pair of y->z 
then we can get rid of useless one then remove left to right and save the first x for last
case:
x y x y z
x y z y z

**
we can split each z then for each block do right to left but we do block left to right
we will also highlight 1 x
for case like x z y z
then we just need to remove everything so the left of the comp is x
will this work??
**
*/
#include "Bruno.h"
#include<iostream>
#include <vector>
using namespace std;
namespace {

int variable_example = 0;

int FunctionExample(int P) { return 1 - P; }

}

void Bruno(int N, int L,vector<int> A){
  int found=0,x=-1;
  vector<int>done(N,0);
  for(int i=0;i<L;i++){
    if(A[i]){
      int cur=i-1;
      while(!A[cur]&&cur>=0){
        if(done[cur])break;
        Remove(cur);
        done[cur]=1;
        cur--;
      }
      if(found&&!done[i]){
        if(done[i])assert(0);
        Remove(i),done[i]=1;
      }
      else x=i;
    }
    found|=A[i];
  }
  if(x!=-1)Remove(x),done[x]=1;
  for(int i=0;i<N;i++)if(!done[i])Remove(i);
}

Compilation message

Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:26:20: error: 'assert' was not declared in this scope
   26 |         if(done[i])assert(0);
      |                    ^~~~~~
Bruno.cpp:3:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    2 | #include<iostream>
  +++ |+#include <cassert>
    3 | #include <vector>
Bruno.cpp: At global scope:
Bruno.cpp:9:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
    9 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
Bruno.cpp:7:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    7 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~