답안 #1071583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071583 2024-08-23T09:04:15 Z 김은성(#11136) Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
45 ms 7900 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, std::vector<char> S) {
	int i, lo = N, hi = -1;
	vector<bool> ch(N);	//checked 1 if invalid
	for(i=0; i<N; i++){
		if(S[i] == 'X'){
			lo = i;
			break;
		}
	}
	for(i=N-1; i>=0; i--){
		if(S[i] == 'Z'){
			hi = i;
			break;
		}
	}
	for(i=0; i<lo; i++)
		ch[i] = 1;
	for(i=hi+1; i<N; i++)
		ch[i] = 1;
	vector<int> send;
	bool flag = 0;
	for(i=lo; i<=hi; i++){
		if(S[i] == 'Y')
			flag = 1;
	}
	if(!flag){
		for(i=0; i<N; i++)
			ch[i] = 1;
	}
	else{
		bool one = 1;
		for(i=lo; i<=hi; i++){
			if(one){
				if(S[i] == 'Y')
					ch[i] = 1;
				else if(S[i] == 'X'){
					send.push_back(0);
					one = 0;
				}
				else{
					send.push_back(1);
					one = 0;
				}
			}
			else{
				if(S[i] == 'Y')
					one = 1;
				else
					ch[i] = 1;
			}
		}
		for(i=hi; i>=lo; i--){
			if(!ch[i])
				break;
		}
		int idx = i;
		ch[idx] = 1;
		ch[hi] = 0;
		send.pop_back();
		send.push_back(1);
	}
	for(i=0; i<N; i++){
		if(!ch[i] && S[i] == 'Z' && i != hi)
			ch[i] = 1;
	}
	for(i=0; i<N; i++)
		Send(ch[i]);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
	int i;
	vector<int> eff;	//value of eff[2*i] = A[n+i]
	//for(i=0; i<L; i++)
	//	printf("%d ", A[i]);
	//printf("\n");
	int hi = -1;
	for(i=0; i<N; i++){
		if(A[i])
			Remove(i);
		else
			hi = i;
	}
	for(i=hi-1; i>=0; i--){
		if(!A[i])
			Remove(i);
	}
	if(hi != -1)
		Remove(hi);
	return;
	for(i=0; i<N; i++){
		if(A[i])
			Remove(i);
		else
			eff.push_back(i);
	}
	if(eff.empty())
		return;
	vector<int> x;
	x.push_back(eff[0]);
	for(i=0; i+1<eff.size() / 2; i++){
		if(A[N+i+1] == 1){
			Remove(eff[2*i+1]);
			Remove(eff[2*i+2]);
		}
		else{
			x.push_back(eff[2*i+1]);
			x.push_back(eff[2*i+2]);
		}
	}
	x.push_back(eff[eff.size()-2]);
	while(!x.empty()){
		Remove(x.back());
		x.pop_back();
	}
	Remove(eff.back());
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(i=0; i+1<eff.size() / 2; i++){
      |           ~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 792 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 7900 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -