Submission #945898

# Submission time Handle Problem Language Result Execution time Memory
945898 2024-03-14T08:32:47 Z siewjh Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
60 ms 10804 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
}

void Anna(int N, vector<char> S) {
	for (int i = 0; i < N; i++){
		int val = S[i] - 'X';
		Send((val & 2) != 0);
		Send((val & 1) != 0);
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
	const int MAXN = 100005;
	int l[MAXN], r[MAXN], nums;
	void rem(int x){
		Remove(x - 1);
		int lx = l[x], rx = r[x];
		r[lx] = rx; l[rx] = lx;
	}
}  // namespace

void Bruno(int N, int L, vector<int> A) {
	nums = N;
	vector<int> vec(nums + 2);
	for (int i = 0; i < nums; i++) vec[i + 1] = ((A[i << 1]) << 1) + A[(i << 1) + 1];
	r[0] = 1;
	for (int i = 1; i <= nums; i++){
		l[i] = i - 1; r[i] = i + 1;
	}
	l[nums + 1] = nums;
	int curr = 1;
	while (curr != nums + 1){
		if (vec[curr] != 1){
			curr = r[curr]; continue;
		}
		if (l[curr] == 0){
			rem(curr); curr = r[curr];
		}
		else if (r[curr] == nums + 1){
			rem(curr); curr = r[curr];
		}
		else if (vec[l[curr]] != 0) rem(l[curr]);
		else if (vec[r[curr]] == 1) rem(r[curr]);
		else if (vec[r[curr]] == 2){
			rem(curr); curr = r[curr];
		}
		else curr = r[curr];
	}
	curr = l[nums + 1];
	while (curr != 0){
		if (vec[curr] != 1){
			curr = l[curr]; continue;
		}
		if (l[curr] == 0){
			rem(curr); curr = l[curr];
		}
		else if (r[curr] == nums + 1){
			rem(curr); curr = l[curr];
		}
		else if (vec[r[curr]] != 2) rem(r[curr]);
		else if (vec[l[curr]] == 1) rem(l[curr]);
		else if (vec[l[curr]] == 0){
			rem(curr); curr = l[curr];
		}
		else curr = l[curr];
	}
	for (int x = r[0]; x != nums + 1; x = r[x]) Remove(x - 1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 792 KB Output is correct
2 Correct 0 ms 792 KB Output is correct
3 Correct 0 ms 780 KB Output is correct
4 Correct 1 ms 788 KB Output is correct
5 Correct 0 ms 780 KB Output is correct
6 Correct 1 ms 784 KB Output is correct
7 Correct 0 ms 784 KB Output is correct
8 Correct 0 ms 784 KB Output is correct
9 Correct 0 ms 796 KB Output is correct
10 Correct 0 ms 796 KB Output is correct
11 Correct 0 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 53 ms 10292 KB Partially correct
2 Incorrect 60 ms 10804 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -