Submission #504050

# Submission time Handle Problem Language Result Execution time Memory
504050 2022-01-09T15:11:31 Z ld_minh4354 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
2000 ms 8536 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

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 Send(1),Send(0);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;


void Bruno(int N, int L,std::vector<int> A) {
  string s;
  int p=-1;
  bool ok;
  for (int i=0;i<L/2;i++)
  {
  	if (A[2*i]==0 and A[2*i+1]==0) s=s+"X";
  	else if (A[2*i]==0 and A[2*i+1]==1) s=s+"Y";
  	else s=s+"Z";
  }
  
  for (int i=0;i<N;i++) if (s[i]!='X') s[i]='A',Remove(i);else
  {
  	p=i;break;
  }
	
  if (p>=0)
  do
  {
	for (int i=p;i<N;i++)
	{
		if (s[i]=='Z')
  		{
  			for (int j=i-1;j>p;j--) if (s[j]!='A') s[j]='A',Remove(j);else break;
  			s[i]='A';Remove(i);
  			p=i+1;
  		}
  		
  	}
  	
  }
  while (p<=N-1);
  
  for (int i=0;i<N;i++) if (s[i]!='A') Remove(i);
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:9:8: warning: unused variable 'ok' [-Wunused-variable]
    9 |   bool ok;
      |        ^~
# Verdict Execution time Memory Grader output
1 Execution timed out 2088 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 8536 KB Time limit exceeded
2 Halted 0 ms 0 KB -