QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185942 | #5671. Programmable Virus | qzez | WA | 0ms | 3628kb | C++14 | 3.5kb | 2023-09-22 20:57:54 | 2023-09-22 20:57:55 |
Judging History
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 add(int x,int y){
static int y0=0;
if(!y0)y0=newnode();
WHILE(y);{
dec(y),inc(x),inc(y0);
}ENDWHILE();
trs(y0,y);
}
void mod(int x,int y){
if(y>9||y<1)return;
int 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 input(int a0,int a1,int tot){
int tmp=newnode();
inc(a0),inc(a1);
read(tmp),inc(tmp);
WHILE(tmp);{
add(tot,tmp),dec(tot),mod(tot,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;
// for(int i=1;i<=25;i++)cout<<i<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
1
output:
ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACUGAUGCACGACGUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUUGAUGAUACAGGACGACGACGACGAGGUACUGUUGAUGAUGAUGAAGGACGACGACGACGACGAGGUACUGUUGAUGAUGAUGAUGAAGGUACACGACGACGACGACGUGCUGAUGAUGAUGAUGAUGUACGACGACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGA...
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2
output:
ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACUGAUGCACGACGUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUUGAUGAUACAGGACGACGACGACGAGGUACUGUUGAUGAUGAUGAAGGACGACGACGACGACGAGGUACUGUUGAUGAUGAUGAUGAAGGUACACGACGACGACGACGUGCUGAUGAUGAUGAUGAUGUACGACGACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGA...
result:
ok correct
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3624kb
input:
3
output:
ACGUGCACGUGCACGACGACGACGACGUCCUGCAGGAGGUACUGAUGCACGACGUGCUGAUGUAGGUACUGUACGAGGUACUGAUGCACGUGUUGAUGAUACAGGACGACGACGACGAGGUACUGUUGAUGAUGAUGAAGGACGACGACGACGACGAGGUACUGUUGAUGAUGAUGAUGAAGGUACACGACGACGACGACGUGCUGAUGAUGAUGAUGAUGUACGACGACGACGACGUACUGAUGAUGCACGACGAGGACGAGGUACUGUUGAAGGUACACGUGCUGAUGUACGUACUGA...
result:
wrong answer but incorrect