답안 #597541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597541 2022-07-16T09:36:33 Z 8e7 레지스터 (IOI21_registers) C++17
33 / 100
1 ms 296 KB
//Challenge: Accepted
#include "registers.h"
#include <bits/stdc++.h>
using namespace std;
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#define ll long long
#define maxn 400005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const int M = 100;
const int B = 2000;

void chmin(int K) {
	append_xor(2, 0, 1);
	{
		int tmp = K - 1;
		int i = 0;
		while (tmp) {
			if (tmp <= (1<<i)) {
				append_right(3, 2, tmp);
				append_or(2, 2, 3);
				tmp = 0;
			} else {
				append_right(3, 2, (1<<i));	
				append_or(2, 2, 3);
				tmp -= 1<<i;
			}
			i++;
		}
	}
	//append_print(2);
	append_right(4, 2, 1);
	append_xor(5, 2, 4); //5: 1 on the different bit
	//append_print(5);
	append_and(6, 1, 5); //check if 6 is 0
	append_print(6);
	append_add(6, 6, 99);
	append_print(6);
	append_right(6, 6, K); // 0 or 1
	append_print(6);
	append_and(6, 6, 99);
	{
		int tmp = K - 1;
		int i = 0;
		while (tmp) {
			if (tmp <= (1<<i)) {
				append_left(7, 6, tmp);
				append_or(6, 6, 7);
				tmp = 0;
			} else {
				append_left(7, 6, (1<<i));
				append_or(6, 6, 7);
				tmp -= 1<<i;
			}
			i++;
		}
	}
	append_not(7, 6);
	append_and(8, 1, 7); 
	append_and(9, 0, 6);
	append_add(0, 8, 9);
}
void solvemin(int N, int K) {
	if (N == 1) return;
	append_right(1, 0, K * (N / 2) * 2);
	chmin(K);
	//append_print(0);
	//append_print(1);
	solvemin((N + 1) / 2, K);
}
void construct_instructions(int tasktype, int N, int K, int q) {
	vector<bool> st(B, 0);
	for (int j = 0;j < N;j += 2) {
		for (int i = 0;i < K;i++) st[j*K + i] = 1;	
	}
	for (int i = N*K;i < B;i++) st[i] = 1;
	append_store(99, st);
	if (tasktype == 0) {
		append_right(1, 0, K);
		append_and(0, 0, 99);
		append_and(1, 1, 99);	
		chmin(K);	
		//append_print(0);
		//append_print(1);
		solvemin((N+1) / 2, K);
	}	
}
/*
0 4 3 1000
1 3 4 2
 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 244 KB Wrong answer detected in grader
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Incorrect sorting
2 Halted 0 ms 0 KB -