Submission #1040502

# Submission time Handle Problem Language Result Execution time Memory
1040502 2024-08-01T06:23:49 Z yanb Bit Shift Registers (IOI21_registers) C++17
10 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "registers.h"
    
using namespace std;
    
//#define int long long
//#define pii pair<long long, long long>

void construct_instructions(int s, int n, int k, int q) {
	vector<bool> empmask(2000);
	for (int i = n * k; i < 2000; i++) empmask[i] = 1;

	append_store(99, empmask);
	append_or(0, 0, 99);           // fill empty space with ones

	while (n > 1) {
		vector<bool> oddmask(2000);
		bool t = 1;
		for (int i = 0; i < 2000; i += k) {
			for (int j = i; j < i + k; j++) {
				oddmask[j] = t;
			}
			t = !t;
		}
		vector<bool> mones(2000, 1);
		for (int i = 2 * k - 1; i < 2000; i += 2 * k) mones[i] = 0;
		vector<bool> ones(2000);
		for (int i = 0; i < 2000; i += 2 * k) ones[i] = 1;

		append_store(90, oddmask); // 90: odd mask
		append_not(91, 90);        // 91: even mask
		append_store(92, mones);   // 92: negative ones
		append_store(93, ones);    // 93: ones
		
		append_and(10, 0, 90);     // 10: odd numbers (A)
		append_and(11, 0, 91);
		append_right(11, 11, k);   // 11: even numbers (B)
		
		append_add(12, 11, 92);
		append_not(12, 12);        
		append_and(12, 12, 92);    // 12: -B
		
		append_add(13, 12, 10);
		append_and(13, 13, 92);    // 13: A - B
		
		append_and(14, 13, 91);
		append_right(14, 14, k); 
		append_and(14, 14, 93);    // 14: [0 / 1] whether A - B is negative, i.e. B > A

		append_add(15, 14, 92);
		append_and(15, 15, 90);    // 15: full if B <= A
		append_xor(16, 15, 90);    // 16: full if B > A
		
		append_and(17, 15, 11);    // 17: smaller is B
		append_and(18, 16, 10);    // 18: smaller is A
		append_or(0, 17, 18);      // 0: the smaller of the two

		k *= 2;
		n = (n + 1) / 2;
	}
}

#ifdef LOCAL
signed main() {
    construct_instructions(0, 2, 2, 1000);
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 0 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect sorting
2 Halted 0 ms 0 KB -