Submission #715208

# Submission time Handle Problem Language Result Execution time Memory
715208 2023-03-26T08:19:06 Z duchuy297 Ancient Machine (JOI21_ancient_machine) C++17
Compilation error
0 ms 0 KB
#include "Anna.h"
#include <vector>

namespace {

int variable_example = 0;

}

void Anna(int N, std::vector<char> S) {
	for (auto u : S) {
		if (u == 'X') Send (0), Send (0);
		else if (u == 'Y') Send (0), Send(1);
		else Send (1), Send(0);
	}
}
#include "Bruno.h"
#include <vector>

namespace {

int variable_example = 0;

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

}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
	string s;
	int n = N;
  for (int i=0; i<2*n; i+=2) {
  	if (s[i] == 0 && s[i+1] == 0) s.push_back('X');
  	else if (s[i] == 0 && s[i+1] == 1) s.push_back('Y');
  	else s.push_back('Z');
   }
   int l = -1, r = -1;
   for (int i=0; i<n; i++) {
   	if (s[i] == 'X') {
   		l = i;
   		break;
	   }
   }
   for (int i=n-1; i>=0; i--) {
   	if (s[i] == 'Z') {
   		r = i;
   		break;
	   }
   }
   if (l == -1 || r == -1) {
   	for (int i=0; i<n; i++) Remove(i);
   	return;
   }
   for (int i=0; i<l; i++) Remove(i);
   for (int i=r+1; i<n; i++) Remove(i);
   stack<int> st;
   st.push(l);
   for (int i=l+1; i<=r; i++) {
   		int u = st.top();
   		if (s[i] == s[u]) {
   			Remove(i);
   			continue;
		   }
		if (s[i] == 'Z') {
			while (st.size() > 1) {
				int u = st.top();
				Remove(u);
				st.pop();
			}
		}
		else st.push(i);
   }
   while (st.size()) {
   	int u = st.top();
   	Remove(u);
   	st.pop();
   }
} 

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:13:2: error: 'string' was not declared in this scope
   13 |  string s;
      |  ^~~~~~
Bruno.cpp:16:8: error: 's' was not declared in this scope
   16 |    if (s[i] == 0 && s[i+1] == 0) s.push_back('X');
      |        ^
Bruno.cpp:22:9: error: 's' was not declared in this scope
   22 |     if (s[i] == 'X') {
      |         ^
Bruno.cpp:28:9: error: 's' was not declared in this scope
   28 |     if (s[i] == 'Z') {
      |         ^
Bruno.cpp:39:4: error: 'stack' was not declared in this scope
   39 |    stack<int> st;
      |    ^~~~~
Bruno.cpp:39:10: error: expected primary-expression before 'int'
   39 |    stack<int> st;
      |          ^~~
Bruno.cpp:40:4: error: 'st' was not declared in this scope; did you mean 'std'?
   40 |    st.push(l);
      |    ^~
      |    std
Bruno.cpp:43:10: error: 's' was not declared in this scope
   43 |      if (s[i] == s[u]) {
      |          ^
Bruno.cpp:47:7: error: 's' was not declared in this scope
   47 |   if (s[i] == 'Z') {
      |       ^
Bruno.cpp: At global scope:
Bruno.cpp:8:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
    8 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
Bruno.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    6 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~