답안 #712607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
712607 2023-03-19T09:47:15 Z dungnguyenn_05 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
62 ms 5684 KB
#include<bits/stdc++.h>
#include <vector>
#include "Anna.h"


void Anna(int N, std::vector<char> S) {

  for(char c:S)
  {
  	if(c=='X')
    {
      Send(0);
      Send(0);
    }

    if(c=='Y')
    {
      Send(0);
      Send(1);
    }

    if(c=='Z')
    {
      Send(1);
      Send(0);
    }
  }
}
#include<bits/stdc++.h>
#include <vector>
#include "Bruno.h"
using namespace std;

char ch[200005];

void Bruno(int N, int L, std::vector<int> A) {
  
  stack<char> st;
  int cnt=0;

  bool ok=0;
  for(int i=0;i<A.size();i+=2)
  {
    int d=A[i];
    int c=A[i+1];

    if(!d and !c)
      ch[cnt]='X';

    if(!d and c)
      ch[cnt]='Y';

    if(d and !c)
      ch[cnt]='Z';

    if(ch[cnt]=='X')
      ok=1;

    if(!ok)
    {
      Remove(cnt);
      continue;
    }

    while(st.size() and st.top()==ch[cnt])
    {
      Remove(st.top());
      st.pop();
    }

    if(ch[cnt]=='X' or ch[cnt]=='Y')
      st.push(cnt);

    if(ch[cnt]=='Z')
    {
      if(ch[st.top()]=='X')
      {
        Remove(st.top());
        st.pop();
      }

      while(st.size()>1)
      {
        Remove(st.top());
        st.pop();
        Remove(st.top());
        st.pop();
      }

      Remove(cnt);
    }
    cnt++;

  }
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int i=0;i<A.size();i+=2)
      |               ~^~~~~~~~~
Bruno.cpp:48:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   48 |       if(ch[st.top()]=='X')
      |             ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 508 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 5684 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -