QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#185944#5671. Programmable VirusqzezAC ✓1ms3628kbC++143.6kb2023-09-22 21:02:102023-09-22 21:02:10

Judging History

你现在查看的是最新测评结果

  • [2023-09-22 21:02:10]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3628kb
  • [2023-09-22 21:02:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
char * cmds[10] =
	{ "CCC", "ACG", "UGA", "UGC", "UAC"
	, "GCG", "UCC", "AGG", "UGU", "CAC"
	};
const int N=1e3+10;
int now,top,stk[N],id[N],*p[N];
string ans;
int cnt;
int newnode(){
	return cnt++;
}
int zero;
void opt(int x){
	ans+=cmds[x];
}
void jump(int x){
	for(;now<x;now++)opt(1);
	for(;now>x;now--)opt(2);
}
void inc(int x){
	jump(x),opt(3);
}
void dec(int x){
	jump(x),opt(4);
}
void WHILE(int x){
	stk[++top]=x;
	jump(x);
	opt(7);
}
void ENDWHILE(){
	jump(stk[top--]);
	opt(8);
}
void clr(int x){
	jump(x);
	WHILE(x);{
		dec(x);
	}ENDWHILE();
}
void trs(int x,int y){
	clr(y);
	WHILE(x);{
		dec(x),inc(y);
	}ENDWHILE();
}
void IF(int &x){
	stk[++top]=x;
	p[top]=&x;
	if(!id[top])id[top]=newnode();
	jump(x);
	opt(7);
	trs(x,id[top]);
	x=id[top];
}
void ENDIF(){
	jump(stk[top]);
	opt(8);
	trs(id[top],stk[top]);
	*p[top]=stk[top];
	top--;
}
void assign(int x,int y){
	jump(x);
	clr(x);
	for(;y--;)opt(3);
}
void read(int x){
	jump(x);
	opt(6);
}
void mod(int x,int y){
	if(y>9||y<1)return;
	static int res=0,flag=0;
	if(!res)res=newnode(),flag=newnode();
	WHILE(x);{
		assign(flag,0);
		for(int i=1;i<=y;i++){
			IF(x),dec(x);
			if(i<y)inc(res);
			else clr(res);
		}
		for(int i=1;i<=y;i++){
			ENDIF();
		}
	}ENDWHILE();
	trs(res,x);
}
void add(int x,int y,int z){
	static int y0=0,y1=0;
	if(!y0)y0=newnode(),y1=newnode();
	WHILE(y);{
		dec(y),inc(y1),inc(y0);
	}ENDWHILE();
	trs(y0,y);
	dec(y1);
	mod(y1,z);
	WHILE(y1);{
		dec(y1),inc(x);
	}ENDWHILE();
	mod(x,z);
}
void input(int a0,int a1,int tot){
	int tmp=newnode();
	inc(a0),inc(a1);
	read(tmp),inc(tmp);
	WHILE(tmp);{
		add(tot,tmp,3);
		trs(a0,a1);
		trs(tmp,a0);
		read(tmp),inc(tmp);
	}ENDWHILE();
	dec(a0),dec(a1);
	// assert(x>=0&&x<=9);
}
int k;
void output(int x){
	jump(x),opt(5),opt(0);
}
int main(){
	cin>>k;
	zero=newnode();
	int a0=newnode(),a1=newnode();
	int b0=newnode(),b1=newnode(),flag=newnode();
	auto add=[&](){
		assign(flag,1);
		IF(b0);{
			IF(b1);{
				clr(flag);
				assign(b0,0),assign(b1,0);
			}ENDIF();
		}ENDIF();
		IF(flag);{
			IF(b0);{
				clr(flag);
				assign(b0,0),assign(b1,1);
			}ENDIF();
		}ENDIF();
		IF(flag);{
			IF(b1);{
				clr(flag);
				assign(b0,1);
			}ENDIF();
		}ENDIF();
		IF(flag);{
			clr(flag);
			assign(b0,1);
		}ENDIF();
	};
	int tot=newnode();
	input(a0,a1,tot);
	if(k==5){
		mod(a0,5);
		int res=newnode();
		assign(res,1);
		IF(a0);{
			assign(res,0);
		}ENDIF();
		output(res);
		cout<<ans<<endl;
		// for(int i=1;i<=25;i++)cout<<i<<endl;
		return 0;
	}
	// debug(a0,a1),opt(9);
	WHILE(a0);{
		add();
		dec(a0);
	}ENDWHILE();
	WHILE(a1);{
		add(),add();
		dec(a1);
	}ENDWHILE();
	int res=newnode();
	if(k%2==0){
		WHILE(b0);{
			dec(b0),inc(res);
		}ENDWHILE();
	}
	// debug(b0,b1),opt(9);
	if(k%4==0){
		WHILE(b1);{
			dec(b1),inc(res);
		}ENDWHILE();
	}
	if(k%3==0){
		WHILE(tot);{
			dec(tot),inc(res);
		}ENDWHILE();
	}
	int p=newnode();
	assign(p,1);
	IF(res);{
		assign(p,0);
	}ENDIF();
	output(p);
	cout<<ans<<endl;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3476kb

input:

1

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

2

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3464kb

input:

3

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 3472kb

input:

6

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

1

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

2

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #7:

score: 0
Accepted
time: 1ms
memory: 3488kb

input:

3

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #8:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

4

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #9:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

5

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

6

output:

ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACACGACGUGCUGAUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUACGUACAGGACGACGAGGUACUGUUGAUGAAGGACGACGACGAGGUACUGUUGAUGAUGAAGGUACACGACGACGUGCUGAUGAUGAUGUACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGAUGAUGAUGCACGACGACGAGGACGAGGUACUGUUGAAGGUACACG...

result:

ok correct