답안 #827550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827550 2023-08-16T14:38:27 Z Amylopectin 레지스터 (IOI21_registers) C++17
33 / 100
1 ms 300 KB
#include "registers.h"
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
const int mxn = 2010;
int ru = 1;
vector<bool> fa[100];
void construct_instructions(int s, int n, int k, int q) 
{
	int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1;
	if(s == 0)
	{
		if(k == 1)
		{
			cn = 0;
			for(i=6; i>=0; i--)
			{
				if((1<<i) < n)
				{
					if(1<<(i+1) >= n)
						append_right(ru,cn,(n - (1<<i)));
					else 
					{
						append_right(ru,cn,(1<<i));
					}
					cm = ru;
					ru ++;
					append_and(cn,cn,cm);
				}
			}
			return ;
		}
		cn = 0;
		ru = 1;
		for(j=0; j<n; j++)
				{
					if(j%2 == 0)
					{
						fa[2].push_back(0);
						fa[3].push_back(1);
						for(o=0; o<k; o++)
						{
							fa[0].push_back(0);
							fa[1].push_back(1);
							if(o > 0)
							{
								fa[2].push_back(0);
								fa[3].push_back(0);
							}
						}
					}
					else 
					{
						fa[2].push_back(1);
						fa[3].push_back(0);
						for(o=0; o<k; o++)
						{
							fa[0].push_back(1);
							fa[1].push_back(0);
							if(o > 0)
							{
								fa[2].push_back(0);
								fa[3].push_back(0);
							}
						}
					}
				}
				for(j=n*k; j<2000; j++)
				{
					fa[0].push_back(0);
					fa[1].push_back(0);
				}
				fa[1][n*k] = 1;
				append_store(ru,fa[0]);
				append_store(ru+1,fa[1]);
				f0 = ru;
				f1 = ru+1;
				ru += 2;
		for(i=6; i>=0; i--)
		{
			if((1<<i) < n)
			{
				ru = 3;
				if(1<<(i+1) >= n)
					append_right(ru,cn,k*(n - (1<<i)));
				else 
				{
					append_right(ru,cn,k*(1<<i));
				}
				cm = ru;
				ru ++;
				append_print(cm);
				cle = (1<<i);
				// fa[0].clear();
				// fa[1].clear();
				// for(j=0; j<cle; j++)
				// {
				// 	if(j%2 == 0)
				// 	{
				// 		fa[2].push_back(0);
				// 		fa[3].push_back(1);
				// 		for(o=0; o<k; o++)
				// 		{
				// 			fa[0].push_back(0);
				// 			fa[1].push_back(1);
				// 			if(o > 0)
				// 			{
				// 				fa[2].push_back(0);
				// 				fa[3].push_back(0);
				// 			}
				// 		}
				// 	}
				// 	else 
				// 	{
				// 		fa[2].push_back(1);
				// 		fa[3].push_back(0);
				// 		for(o=0; o<k; o++)
				// 		{
				// 			fa[0].push_back(1);
				// 			fa[1].push_back(0);
				// 			if(o > 0)
				// 			{
				// 				fa[2].push_back(0);
				// 				fa[3].push_back(0);
				// 			}
				// 		}
				// 	}
				// }
				// for(j=cle*k; j<2000; j++)
				// {
				// 	fa[0].push_back(0);
				// 	fa[1].push_back(0);
				// }
				// fa[1][cle*k] = 1;
				// append_store(ru,fa[0]);
				// append_store(ru+1,fa[1]);
				append_not(ru+2,cm);
				append_and(ru+3,cn,f0);
				append_and(ru+4,ru+2,f0);
				append_and(ru+5,cn,f1);
				append_and(ru+6,ru+2,f1);
				append_add(ru+7,ru+3,ru+4);
				append_add(ru+8,ru+5,ru+6);
				append_and(ru+9,ru+7,f1);
				append_and(ru+10,ru+8,f0);

				append_or(ru+11,ru+9,ru+10);
				append_right(ru+12,ru+11,k);
				for(j=2; j<13; j++)
				{
					append_print(ru+j);
				}
				fn = ru+12;
				for(j=0; j<4; j++)
				{
					if((1<<(j+1)) < k)
					{
						append_left(fn+1,fn,(1<<j));
						append_or(fn,fn,fn+1);
					}
					else 
					{
						append_left(fn+1,fn,k-(1<<j));
						append_or(fn,fn,fn+1);
						break;
					}
				}
				append_and(fn+2,fn,cm);
				append_not(fn+3,fn);
				append_and(fn+4,fn+3,cn);
				append_or(0,fn+2,fn+4);
				for(j=0; j<5; j++)
				{
					append_print(fn+j);
				}
				cn = 0;
				append_print(0);
			}
		}
		return ;
	}
	append_move(1, 0);
	append_right(1, 1, 1);
	append_and(0, 0, 1);
}

Compilation message

registers.cpp: In function 'void construct_instructions(int, int, int, int)':
registers.cpp:11:19: warning: unused variable 'fm' [-Wunused-variable]
   11 |  int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1;
      |                   ^~
registers.cpp:11:22: warning: variable 'cle' set but not used [-Wunused-but-set-variable]
   11 |  int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1;
      |                      ^~~
registers.cpp:11:28: warning: unused variable 'p' [-Wunused-variable]
   11 |  int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1;
      |                            ^
registers.cpp:11:30: warning: unused variable 'h' [-Wunused-variable]
   11 |  int i,j,cn,cm,fn,fm,cle,o,p,h,f0,f1;
      |                              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 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 -