QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#132334 | #5660. Simplified Genome Translation | willow# | Compile Error | / | / | C++14 | 4.0kb | 2023-07-29 16:30:52 | 2023-07-29 16:30:52 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-29 16:30:52]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-29 16:30:52]
- 提交
answer
simulator
/* simu.c */
/* gcc -o simu simu.c */
#include <stdio.h>
#include <string.h>
char* cmds[10] = {"CCC", "ACG", "UGA", "UGC", "UAC", "GCG" , "UCC" , "AGG" , "UGU" , "CAC"};
char* codes[10] = {"Stop", "Next", "Prev", "Inc", "Dec", "Out", "In", "Begin", "End", "Debug"};
char code[1000002], memory[2000001], input[1000001];
static inline int get_cmd(char* code) {
for(int i = 9; i >= 0; -- i)
if(strncmp(cmds[i], code, 3) == 0)
return i;
return -1;
}
int main() {
if(!fgets(code, 1000002, stdin)) {
puts("no code");
return 1;
}
int code_len = strlen(code);
if(code[code_len - 1] != '\n') {
puts("code too long");
return 1;
}
code[-- code_len] = 0;
// char *ip = code;
// while(code + code_len - ip >= 3) {
// int f = 0;
// for(int i = 0; i <= 9; ++ i) {
// if(strncmp(cmds[i], ip, 3) == 0) {
// puts(codes[i]);
// f = 1;
// break;
// }
// }
// if(!f)
// puts("None");
// ip += 3;
// }
// return 0;
while(fgets(input, 1000001, stdin)) {
char* ip = code, *input_p = input;
char* mem = memory + 1000000;
char* mem_begin = mem, *mem_end = mem;
*mem = 0 ;
int step = 0, eof = 0 ;
while(1) {
if(step == 1000000) {
puts("step out of bound");
break;
}
if(code + code_len - ip < 3) {
puts("code out of bound");
break;
}
int cmd = get_cmd(ip);
if(cmd < 0) {
printf("invalid code point : %c%c%c \n ", ip[0], ip[1], ip[2]);
break;
}
if(cmd == 0) {
puts("stop no rmally");
break ;
}
if(cmd == 1) {
++ mem;
if(mem > mem_end )
*++ mem_end = 0;
}
else if(cmd == 2) {
--mem;
if(mem < mem_begin)
*-- mem_begin = 0;
}
else if(cmd == 3) {
if(*mem == 9)
*mem = -1;
else
++ *mem;
}
else if(cmd == 4) {
if(*mem == -1)
*mem = 9;
else
-- *mem;
}
else if(cmd == 5) {
if(*mem == -1)
putchar('-');
else
putchar('0' + *mem);
}
else if(cmd == 6) {
while(1) {
if(!*input_p || *input_p == '\n') {
*mem = -1;
break;
}
if(*input_p == '-') {
*mem = -1;
++ input_p;
break;
}
if('0' <= *input_p && *input_p <= '9') {
*mem = *input_p ++ - '0';
break;
}
++ input_p;
}
}
else if(cmd == 7) {
if(!*mem) {
int skip = 1 ;
while(skip) {
ip += 3;
if(code + code_len - ip < 3 ) {
puts("7 can't find matched 8");
goto END;
}
if(strncmp(cmds[8], ip, 3) == 0)
-- skip;
else if(strncmp(cmds[7], ip, 3) == 0)
++ skip;
}
}
}
else if(cmd == 8) {
if(*mem) {
int skip = 1 ;
while(skip) {
ip -= 3 ;
if(ip < code ) {
puts("8 can't find matched 7");
goto END;
}
if(strncmp(cmds[7], ip, 3) == 0)
-- skip ;
else if(strncmp(cmds[8], ip, 3) == 0)
++ skip ;
}
}
}
else if(cmd == 9) {
printf("\n step: %d, state: " , step);
for(char* p = mem_begin; p <= mem_end; ++ p)
if(p == mem)
printf("[%c] ", *p < 0 ? '-' : '0' + *p);
else
putchar(*p < 0 ? '-' : '0' + *p);
printf(", code: ");
for(char* p = code; p < code + code_len; p += 3)
printf("%c%c%c%c " , p == ip ? '[' : p == ip + 3 ? ']' : ' ', p[0], p[1], p[2]);
if(code + code_len == ip + 3)
putchar(']');
puts("");
-- step;
}
++ step;
ip += 3;
}
END: ;
}
return 0 ;
}
/*
k = 2:
Inc
Begin
Dec
Next
Begin
Dec
End
Prev
Begin
Dec
Next
Inc
Prev
End
In
Inc
End
Next
Inc
Begin
Dec
Prev
Inc
Next
Begin
Dec
Prev
Dec
Next
Begin
Dec
Prev
Inc
Next
Begin
Dec
Prev
Dec
Next
Begin
Dec
Prev
Inc
Next
Begin
Dec
Prev
Dec
Next
Begin
Dec
Prev
Inc
Next
Begin
Dec
Prev
Dec
Next
Begin
Dec
Prev
Inc
Next
Begin
Dec
Prev
Dec
Next
End
End
End
End
End
End
End
End
End
End
Prev
Out
Stop
*/
Details
answer.code:1:1: error: ‘simulator’ does not name a type 1 | simulator | ^~~~~~~~~ In file included from answer.code:5: /usr/include/string.h:44:22: error: ‘size_t’ has not been declared 44 | size_t __n) __THROW __nonnull ((1, 2)); | ^~~~~~ /usr/include/string.h:47:56: error: ‘size_t’ has not been declared 47 | extern void *memmove (void *__dest, const void *__src, size_t __n) | ^~~~~~ /usr/include/string.h:55:32: error: ‘size_t’ has not been declared 55 | int __c, size_t __n) | ^~~~~~ /usr/include/string.h:61:42: error: ‘size_t’ has not been declared 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ /usr/include/string.h:64:56: error: ‘size_t’ has not been declared 64 | extern int memcmp (const void *__s1, const void *__s2, size_t __n) | ^~~~~~ /usr/include/string.h:71:42: error: ‘size_t’ has not been declared 71 | extern void *memchr (void *__s, int __c, size_t __n) | ^~~~~~ /usr/include/string.h:73:54: error: ‘size_t’ has not been declared 73 | extern const void *memchr (const void *__s, int __c, size_t __n) | ^~~~~~ /usr/include/string.h:78:29: error: ‘size_t’ has not been declared 78 | memchr (void *__s, int __c, size_t __n) __THROW | ^~~~~~ /usr/include/string.h:84:35: error: ‘size_t’ has not been declared 84 | memchr (const void *__s, int __c, size_t __n) __THROW | ^~~~~~ /usr/include/string.h:110:49: error: ‘size_t’ has not been declared 110 | extern "C++" void *memrchr (void *__s, int __c, size_t __n) | ^~~~~~ /usr/include/string.h:112:61: error: ‘size_t’ has not been declared 112 | extern "C++" const void *memrchr (const void *__s, int __c, size_t __n) | ^~~~~~ /usr/include/string.h:126:53: error: ‘size_t’ has not been declared 126 | const char *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:134:23: error: ‘size_t’ has not been declared 134 | size_t __n) __THROW __nonnull ((1, 2)); | ^~~~~~ /usr/include/string.h:140:57: error: ‘size_t’ has not been declared 140 | extern int strncmp (const char *__s1, const char *__s2, size_t __n) | ^~~~~~ /usr/include/string.h:147:8: error: ‘size_t’ does not name a type 147 | extern size_t strxfrm (char *__restrict __dest, | ^~~~~~ /usr/include/string.h:34:1: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’? 33 | #include <stddef.h> +++ |+#include <cstddef> 34 | In file included from answer.code:5: /usr/include/string.h:160:8: error: ‘size_t’ does not name a type 160 | extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, | ^~~~~~ /usr/include/string.h:160:8: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’? /usr/include/string.h:175:45: error: ‘size_t’ has not been declared 175 | extern char *strndup (const char *__string, size_t __n) | ^~~~~~ /usr/include/string.h:273:8: error: ‘size_t’ does not name a type 273 | extern size_t strcspn (const char *__s, const char *__reject) | ^~~~~~ /usr/include/string.h:273:8: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’? /usr/include/string.h:277:8: error: ‘size_t’ does not name a type 277 | extern size_t strspn (const char *__s, const char *__accept) | ^~~~~~ /usr/include/string.h:277:8: note: ‘size_t’ is defined in header ‘<cstddef>’; did you forget to ‘#include <cstddef>’? /usr/include/string.h:369:46: error: ‘size_t’ has not been declared 369 | extern void *memmem (const void *__haystack, size_t __haystacklen, | ^~~~~~ /usr/include/string.h:370:44: error: ‘size_t’ has not been declared 370 | const void *__needle, size_t __needlelen) | ^~~~~~ /usr/include/string.h:376:55: error: ‘size_t’ has not been declared 376 | const void *__restrict __src, size_t __n) | ^~~~~~ /usr/include/string.h:379:53: error: ‘size_t’ has not been declared 379 | const void *__restrict __src, size_t __n) |...