Submission #1048693

# Submission time Handle Problem Language Result Execution time Memory
1048693 2024-08-08T09:07:49 Z AmirAli_H1 Bit Shift Registers (IOI21_registers) C++17
60 / 100
1 ms 788 KB
// In the name of Allah

#include <bits/stdc++.h>
#include "registers.h"
using namespace std;

typedef		long long				ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;

#define		endl					'\n'
#define		sep						' '
#define		F						first
#define		S						second
#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		pb						push_back
#define		Mp						make_pair

const int M = 100;

int n, k, q, R, Rx;
vector<bool> vc;

void solve(int md, int n, int k) {
	if (n == 1) {
		if (md == 1) {
			append_left(0, 0, R * k);
			append_or(M - 23, M - 23, 0);
		}
		R++;
		return ;
	}
	
	int j = (n / 2) * (2 * k);
	append_right(1, 0, j);
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < j; i++) vc[i] = 1;
	append_store(2, vc); append_and(0, 0, 2);
	
	int m = (n / 2); n -= m;
	append_xor(2, 0, M - 3);
	append_add(2, 2, M - 4);
	append_add(3, 1, 2);
	
	append_and(3, 3, M - 5);
	append_right(3, 3, k);
	append_left(4, 3, 2 * k);
	
	append_not(3, 3); append_add(3, 3, M - 6);
	
	append_add(3, 3, 4);
	append_not(4, 3);
	
	append_and(5, 0, 3);
	append_and(6, 1, 4);
	if (md == 1) {
		append_and(7, 0, 4);
		append_and(8, 1, 3);
	}
	
	append_or(0, 5, 6);
	if (md == 1) {
		append_or(1, 7, 8);
		append_left(1, 1, Rx * (2 * k));
		append_or(10, 10, 1);
	}
	
	Rx += m;
	solve(md, n, k);
}

void construct_instructions(int md, int nx, int kx, int qx) {
	n = nx; k = kx; q = qx;
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < n * k; i++) {
		if (i % (2 * k) < k) vc[i] = 1;
	}
	append_store(M - 1, vc);
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < n * k; i++) {
		if (i % (2 * k) >= k) vc[i] = 1;
	}
	append_store(M - 2, vc);
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < 2000; i++) {
		if (i % (2 * k) <= k) vc[i] = 1;
	}
	append_store(M - 3, vc);
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < 2000; i++) {
		if (i % (2 * k) == 0) vc[i] = 1;
	}
	append_store(M - 4, vc);
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < 2000; i++) {
		if (i % (2 * k) == k) vc[i] = 1;
	}
	append_store(M - 5, vc);
	
	vc.clear(); vc.resize(2000); vc[0] = 1;
	append_store(M - 6, vc);
	
	vc.clear(); vc.resize(2000);
	for (int i = 0; i < n * k; i++) vc[i] = 1;
	append_store(M - 7, vc);
	
	append_xor(0, 0, M - 7);
	
	append_and(1, 0, M - 1); append_and(2, 0, M - 2);
	int j = n * k;
	if (n % 2 == 1) j += k;
	append_left(2, 2, j - k);
	
	append_or(0, 1, 2);
	
	if (md == 0) solve(md, n, k);
	else {
		R = 0;
		for (int i = n; i >= 1; i--) {
			Rx = 0;
			solve(md, i, k);
			append_move(0, 10);
			append_left(10, 10, 2000);
		}
		append_move(0, M - 23);
	}
	
	append_xor(0, 0, M - 7);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 420 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Incorrect 1 ms 788 KB Wrong answer detected in grader
4 Halted 0 ms 0 KB -