Submission #1366687

#TimeUsernameProblemLanguageResultExecution timeMemory
1366687wangzhiyi33Ancient Machine (JOI21_ancient_machine)C++20
30 / 100
42 ms6944 KiB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 0;

}

void Anna(int N, vector<char> s) {
  int x=-1,z=-2;
  for(int q=0;q<N;q++){
    if(s[q]=='X'){  
      if(x==-1){
        x=q; 
      }
    }
    else if(s[q]=='Z'){
      z=q;
    }
  }
  if(x==-1 || z==-2)return;
  for(int q=0;q<x;q++)Send(0);
  Send(1);
  for(int q=x+1;q<=z;q++){
    if(s[q]=='Z')Send(1);
    else Send(0);
  }
  for(int q=z+1;q<N;q++)Send(0);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 0;

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

}  // namespace

void Bruno(int N, int L, vector<int> A) {
  if(A.empty()){
    for(int q=0;q<N;q++){
      Remove(q);
    }
    return;
  }

  int x=-1;
  for(int q=0;q<L;q++){
    if(A[q]){
      x=q; break;
    }
    else{
      Remove(q);
    }
  }

  int lst=N-1;
  for(int q=N-1;q>=0;q--){
    if(A[q]==1){
      lst=q; break;
    }
    Remove(q);
  }

  int prv=x+1,cur=x+1;

  while(cur<=lst){
    for(int q=cur;q<=lst;q++){
      if(A[q]){
        for(int w=q-1;w>=prv;w--){
          Remove(w);
        }
        Remove(q);
        prv=q+1,cur=prv; 
        break;
      }
      else{
        continue;
      }
    }
    
  }
  //cout<<x<<endl;
  Remove(x);

}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...