답안 #1071556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071556 2024-08-23T08:43:45 Z 김은성(#11136) Ancient Machine (JOI21_ancient_machine) C++17
45 / 100
63 ms 9496 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++)
		Send(ch[i]);
	for(int u: send)
		Send(u);
}
#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");
	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:20:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(i=0; i+1<eff.size() / 2; i++){
      |           ~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 780 KB Output is correct
2 Correct 1 ms 780 KB Output is correct
3 Correct 0 ms 792 KB Output is correct
4 Correct 0 ms 792 KB Output is correct
5 Correct 0 ms 784 KB Output is correct
6 Correct 0 ms 780 KB Output is correct
7 Correct 0 ms 792 KB Output is correct
8 Correct 0 ms 780 KB Output is correct
9 Correct 0 ms 780 KB Output is correct
10 Correct 0 ms 780 KB Output is correct
11 Correct 0 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 41 ms 8392 KB Partially correct
2 Partially correct 41 ms 8328 KB Partially correct
3 Partially correct 59 ms 8380 KB Partially correct
4 Partially correct 41 ms 8356 KB Partially correct
5 Partially correct 59 ms 8268 KB Partially correct
6 Partially correct 41 ms 8324 KB Partially correct
7 Partially correct 50 ms 8664 KB Partially correct
8 Partially correct 41 ms 8484 KB Partially correct
9 Partially correct 44 ms 8252 KB Partially correct
10 Partially correct 48 ms 8396 KB Partially correct
11 Partially correct 50 ms 8392 KB Partially correct
12 Partially correct 40 ms 8376 KB Partially correct
13 Partially correct 60 ms 9440 KB Partially correct
14 Partially correct 56 ms 9264 KB Partially correct
15 Partially correct 38 ms 8948 KB Partially correct
16 Partially correct 49 ms 9112 KB Partially correct
17 Partially correct 47 ms 7896 KB Partially correct
18 Partially correct 48 ms 7904 KB Partially correct
19 Partially correct 43 ms 7884 KB Partially correct
20 Partially correct 44 ms 9308 KB Partially correct
21 Partially correct 41 ms 9496 KB Partially correct
22 Partially correct 41 ms 7964 KB Partially correct
23 Partially correct 46 ms 9080 KB Partially correct
24 Partially correct 63 ms 8872 KB Partially correct
25 Partially correct 49 ms 8132 KB Partially correct
26 Partially correct 50 ms 7932 KB Partially correct
27 Partially correct 63 ms 8060 KB Partially correct
28 Partially correct 45 ms 8024 KB Partially correct
29 Partially correct 41 ms 7944 KB Partially correct
30 Partially correct 48 ms 7872 KB Partially correct
31 Partially correct 57 ms 7884 KB Partially correct
32 Partially correct 46 ms 8380 KB Partially correct
33 Partially correct 51 ms 8356 KB Partially correct