├── .gitignore ├── LICENSE ├── README.md ├── codegen ├── data.csv ├── e1.c ├── e1.mx ├── e10.c ├── e10.mx ├── e2.c ├── e2.mx ├── e3.c ├── e3.mx ├── e4.c ├── e4.mx ├── e5.c ├── e5.mx ├── e6.c ├── e6.mx ├── e7.c ├── e7.mx ├── e8.c ├── e8.mx ├── e9.c ├── e9.mx ├── judgelist.txt ├── process.py ├── shortest_path │ ├── dijkstra.mx │ ├── floyd.mx │ └── spfa.mx ├── sorting │ ├── bubble_sort.mx │ ├── merge_sort.mx │ ├── quick_sort.mx │ └── selection_sort.mx ├── std │ └── queue.mt ├── t1.cpp ├── t1.mx ├── t10.cpp ├── t10.mx ├── t11.cpp ├── t11.mx ├── t12.mx ├── t13.mx ├── t14.mx ├── t15.mx ├── t16.mx ├── t17.cpp ├── t17.mx ├── t18.mx ├── t19.mx ├── t2.cpp ├── t2.mx ├── t20.mx ├── t21.mx ├── t22.mx ├── t23.mx ├── t24.mx ├── t25.mx ├── t26.mx ├── t27.mx ├── t28.mx ├── t29.mx ├── t3.cpp ├── t3.mx ├── t30.mx ├── t31.mx ├── t32.mx ├── t33.mx ├── t34.mx ├── t35.mx ├── t36.mx ├── t37.mx ├── t38.mx ├── t39.mx ├── t4.cpp ├── t4.mx ├── t40.mx ├── t41.mx ├── t42.mx ├── t43.mx ├── t44.mx ├── t45.mx ├── t46.mx ├── t47.mx ├── t48.mx ├── t49.mx ├── t5.cpp ├── t5.mx ├── t50.mx ├── t51.mx ├── t52.mx ├── t53.mx ├── t54.mx ├── t55.mx ├── t56.mx ├── t57.mx ├── t58.mx ├── t59.mx ├── t6.cpp ├── t6.mx ├── t60.mx ├── t61.mx ├── t62.mx ├── t63.mx ├── t64.mx ├── t66.mx ├── t67.mx ├── t68.mx ├── t69.mx ├── t7.cpp ├── t7.mx ├── t70.mx ├── t8.cpp ├── t8.mx ├── t9.cpp └── t9.mx ├── codegen2 ├── shortest_path │ ├── dijkstra.mx │ ├── edge_list.mh │ ├── floyd.mx │ ├── gen_data.py │ ├── shortest_path.0.ans │ ├── shortest_path.0.in │ ├── shortest_path.1.ans │ ├── shortest_path.1.in │ └── spfa.mx ├── sorting │ ├── bubble_sort.mx │ ├── main.mt │ ├── merge_sort.mx │ ├── quick_sort.mx │ ├── selection_sort.mx │ ├── sorting.ans │ └── sorting.in └── std │ ├── array.mh │ ├── heap.mh │ ├── heap.mt │ ├── queue.mh │ ├── queue.mt │ └── slice.mh ├── deprecated └── t65.mx ├── optim ├── binary_tree.mx ├── dijkstra.mx ├── humble.mx ├── kruskal.mx ├── lca.mx ├── lunatic.mx ├── maxflow.mx ├── pi.mx ├── segtree.mx └── sha_1.mx ├── optim2 ├── binary_tree.ans ├── binary_tree.in ├── binary_tree.mx ├── dijkstra.ans ├── dijkstra.in ├── dijkstra.mx ├── humble.ans ├── humble.in ├── humble.mx ├── kruskal.ans ├── kruskal.in ├── kruskal.mx ├── lca.ans ├── lca.in ├── lca.mx ├── lunatic.ans ├── lunatic.in ├── lunatic.mx ├── maxflow.ans ├── maxflow.in ├── maxflow.mx ├── pi.ans ├── pi.in ├── pi.mx ├── segtree.ans ├── segtree.in ├── segtree.mx ├── sha_1.ans ├── sha_1.in └── sha_1.mx ├── script ├── gen.py └── preprocess.py └── sema ├── array-package ├── array-1.mx ├── array-10.mx ├── array-11.mx ├── array-2.mx ├── array-3.mx ├── array-4.mx ├── array-5.mx ├── array-6.mx ├── array-7.mx ├── array-8.mx └── array-9.mx ├── basic-package ├── basic-1.mx ├── basic-10.mx ├── basic-11.mx ├── basic-12.mx ├── basic-13.mx ├── basic-14.mx ├── basic-15.mx ├── basic-16.mx ├── basic-17.mx ├── basic-18.mx ├── basic-19.mx ├── basic-2.mx ├── basic-20.mx ├── basic-21.mx ├── basic-22.mx ├── basic-23.mx ├── basic-24.mx ├── basic-25.mx ├── basic-26.mx ├── basic-27.mx ├── basic-28.mx ├── basic-29.mx ├── basic-3.mx ├── basic-30.mx ├── basic-31.mx ├── basic-32.mx ├── basic-33.mx ├── basic-34.mx ├── basic-35.mx ├── basic-36.mx ├── basic-37.mx ├── basic-38.mx ├── basic-39.mx ├── basic-4.mx ├── basic-40.mx ├── basic-41.mx ├── basic-42.mx ├── basic-43.mx ├── basic-44.mx ├── basic-45.mx ├── basic-46.mx ├── basic-47.mx ├── basic-48.mx ├── basic-49.mx ├── basic-5.mx ├── basic-50.mx ├── basic-51.mx ├── basic-52.mx ├── basic-53.mx ├── basic-54.mx ├── basic-55.mx ├── basic-56.mx ├── basic-57.mx ├── basic-58.mx ├── basic-59.mx ├── basic-6.mx ├── basic-60.mx ├── basic-61.mx ├── basic-62.mx ├── basic-63.mx ├── basic-64.mx ├── basic-65.mx ├── basic-66.mx ├── basic-67.mx ├── basic-68.mx ├── basic-69.mx ├── basic-7.mx ├── basic-70.mx ├── basic-71.mx ├── basic-8.mx └── basic-9.mx ├── bool-compare.mx ├── breakcontinue-package ├── breakcontinue-1.mx ├── breakcontinue-2.mx ├── breakcontinue-3.mx ├── breakcontinue-4.mx └── breakcontinue-5.mx ├── builtin-func-package ├── builtin-1.mx ├── builtin-2.mx ├── builtin-3.mx └── builtin-4.mx ├── class-package ├── class-1.mx ├── class-10.mx ├── class-11.mx ├── class-12.mx ├── class-13.mx ├── class-14.mx ├── class-15.mx ├── class-16.mx ├── class-2.mx ├── class-3.mx ├── class-4.mx ├── class-5.mx ├── class-6.mx ├── class-7.mx ├── class-8.mx └── class-9.mx ├── codeforces-package ├── 1145A.mx ├── 122A.mx ├── 158A.mx ├── 1A.mx ├── 231A.mx ├── 263A.mx ├── 399A.mx ├── 4A.mx ├── 69A.mx └── 71A.mx ├── condition.mx ├── data.txt ├── expression-package ├── expression-1.mx ├── expression-2.mx ├── expression-3.mx ├── expression-4.mx └── expression-5.mx ├── function-package ├── function-1.mx ├── function-2.mx ├── function-3.mx ├── function-4.mx ├── function-5.mx └── function-6.mx ├── if-package ├── if-1.mx ├── if-2.mx └── if-3.mx ├── judgelist.txt ├── loop-package ├── loop-1.mx ├── loop-2.mx └── loop-3.mx ├── misc-package ├── misc-1.mx ├── misc-10.mx ├── misc-11.mx ├── misc-12.mx ├── misc-13.mx ├── misc-14.mx ├── misc-15.mx ├── misc-16.mx ├── misc-17.mx ├── misc-18.mx ├── misc-19.mx ├── misc-2.mx ├── misc-20.mx ├── misc-21.mx ├── misc-22.mx ├── misc-23.mx ├── misc-24.mx ├── misc-25.mx ├── misc-26.mx ├── misc-27.mx ├── misc-28.mx ├── misc-29.mx ├── misc-3.mx ├── misc-30.mx ├── misc-31.mx ├── misc-32.mx ├── misc-33.mx ├── misc-34.mx ├── misc-35.mx ├── misc-36.mx ├── misc-37.mx ├── misc-4.mx ├── misc-5.mx ├── misc-6.mx ├── misc-7.mx ├── misc-8.mx └── misc-9.mx ├── old_sema_list.txt ├── scope-package ├── scope-1.mx ├── scope-2.mx ├── scope-3.mx ├── scope-4.mx ├── scope-5.mx ├── scope-6.mx ├── scope-7.mx └── scope-8.mx ├── string-package └── string-1.mx ├── symbol-package ├── symbol-1.mx ├── symbol-2.mx ├── symbol-3.mx ├── symbol-4.mx ├── symbol-5.mx ├── symbol-6.mx └── symbol-7.mx └── test.mx /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Wenxin Zheng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Compiler 2020 testcases 2 | -------------------------------------------------------------------------------- /codegen/e1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 17 5 2 8 | === end === 9 | Output: 10 | === output === 11 | << 3 4 (5) 6 7 >> 12 | === end === 13 | ExitCode: 10 14 | InstLimit: -1 15 | Origin Package: Codeforces 399A #44003944 16 | */ 17 | #include 18 | int main() { 19 | int n,p,k; 20 | scanf("%d%d%d",&n,&p,&k); 21 | if(p-k>1) printf("<< "); 22 | for(int i= p-k; i<=p+k;i++) 23 | if(1<= i && i <= n) { 24 | if(i==p)printf( "(%d) ",i); 25 | else printf("%d ", i); 26 | } 27 | if(p + k < n) printf(">> "); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /codegen/e1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 79 35 12 8 | === end === 9 | Output: 10 | === output === 11 | << 23 24 25 26 27 28 29 30 31 32 33 34 (35) 36 37 38 39 40 41 42 43 44 45 46 47 >> 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 399A #44003944 16 | */ 17 | int n; 18 | int p; 19 | int k; 20 | int i; 21 | int main() { 22 | n = getInt(); 23 | p = getInt(); 24 | k = getInt(); 25 | if(p-k>1) print("<< "); 26 | for(i= p-k; i<=p+k;i++) 27 | if(1<= i && i <= n) { 28 | if(i==p){ 29 | print("("); 30 | print(toString(i)); 31 | print(") "); 32 | } 33 | else{ 34 | printInt(i); 35 | print(" "); 36 | } 37 | } 38 | if(p + k < n) print(">> "); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /codegen/e10.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 47 8 | === end === 9 | Output: 10 | === output === 11 | YES 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 122A #61467904 16 | */ 17 | #include 18 | int main() 19 | { 20 | int n; 21 | scanf("%d",&n); 22 | printf((n%4==0)||(n%7==0)||(n%47==0)||(n%74==0)||(n%477==0) ? "YES" : "NO"); 23 | } -------------------------------------------------------------------------------- /codegen/e10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 47 8 | === end === 9 | Output: 10 | === output === 11 | YES 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 122A #61467904 16 | */ 17 | int n; 18 | int main() 19 | { 20 | //int n; 21 | //scanf("%d",&n); 22 | n = getInt(); 23 | if((n%4==0)||(n%7==0)||(n%47==0)||(n%74==0)||(n%477==0)) 24 | print("YES"); 25 | else 26 | print("NO"); 27 | // printf((n%4==0)||(n%7==0)||(n%47==0)||(n%74==0)||(n%477==0) ? "YES" : "NO"); 28 | } -------------------------------------------------------------------------------- /codegen/e2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 8 8 | 11 12 1 2 13 14 3 4 9 | === end === 10 | Output: 11 | === output === 12 | 2 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codeforces 1145A #52445759 17 | */ 18 | #include 19 | int n,a[20]; 20 | int jud(int x){ 21 | int i,j; 22 | for(i=0;ia[i*x+j+1])flag=1; 26 | } 27 | if(!flag)return 1; 28 | } 29 | return 0; 30 | } 31 | int main(){ 32 | int i; 33 | scanf("%d",&n); 34 | for(i=0;i>=1)if(jud(i))return printf("%d",i),0; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /codegen/e2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 8 8 | 11 12 1 2 13 14 3 4 9 | === end === 10 | Output: 11 | === output === 12 | 2 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codeforces 1145A #52445759 17 | */ 18 | int n; 19 | int[] a = new int[20]; 20 | int jud(int x){ 21 | int i,j; 22 | for(i=0;ia[i*x+j+1])flag=true; 26 | } 27 | if(!flag)return 1; 28 | } 29 | return 0; 30 | } 31 | int i; 32 | int main(){ 33 | n = getInt(); 34 | for(i=0;i 0;i = i / 2) 36 | if(jud(i) > 0){ 37 | print(toString(i)); 38 | return 0; 39 | } 40 | return 0; 41 | } -------------------------------------------------------------------------------- /codegen/e3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 1 8 | === end === 9 | Output: 10 | === output === 11 | NO 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 4A #57460997 16 | */ 17 | #include 18 | int main(){ 19 | int w; 20 | scanf("%d",&w); 21 | (w%2==0&&w>2)?printf("YES"):printf("NO"); 22 | } -------------------------------------------------------------------------------- /codegen/e3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 1 8 | === end === 9 | Output: 10 | === output === 11 | NO 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 4A #57460997 16 | */ 17 | int w; 18 | int main(){ 19 | w = getInt(); 20 | if ((w%2==0)&& (w>2)) 21 | print("YES"); 22 | else 23 | print("NO"); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /codegen/e4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 1001 1000 10 8 | === end === 9 | Output: 10 | === output === 11 | 10100 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 1A #52940143 16 | */ 17 | int n,m,a; 18 | int main(){ 19 | scanf("%d%d%d",&n,&m,&a); 20 | printf("%I64d",(m+a-1ll)/a*((n+a-1)/a)); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /codegen/e4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 1001 1000 10 8 | === end === 9 | Output: 10 | === output === 11 | 10100 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codeforces 1A #52940143 16 | */ 17 | int n,m,a; 18 | int main(){ 19 | n = getInt(); 20 | m = getInt(); 21 | a = getInt(); 22 | print(toString((m+a-1)/a*((n+a-1)/a))); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /codegen/e5.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 3 8 | njfngnrurunrgunrunvurn 9 | jfvnjfdnvjdbfvsbdubruvbubvkdb 10 | ksdnvidnviudbvibd 11 | === end === 12 | Output: 13 | === output === 14 | n20n 15 | j27b 16 | k15d 17 | === end === 18 | ExitCode: 0 19 | InstLimit: -1 20 | Origin Package: Codeforces 71A #53307259 21 | */ 22 | #include 23 | #include 24 | 25 | int main(){ 26 | int t,l; 27 | char s[100]; 28 | scanf("%d",&t); 29 | while(t--){ 30 | scanf("%s",s); 31 | l = strlen(s); 32 | if(l > 10) 33 | printf("%c%d%c\n",s[0],l-2,s[l-1]); 34 | else 35 | printf("%s\n",s); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /codegen/e5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 3 8 | njfngnrurunrgunrunvurn 9 | jfvnjfdnvjdbfvsbdubruvbubvkdb 10 | ksdnvidnviudbvibd 11 | === end === 12 | Output: 13 | === output === 14 | n20n 15 | j27b 16 | k15d 17 | === end === 18 | ExitCode: 0 19 | InstLimit: -1 20 | Origin Package: Codeforces 71A #53307259 21 | */ 22 | int t,l,i; 23 | string s; 24 | int main(){ 25 | t = getInt(); 26 | for(i=0;i 10) 30 | println(s.substring(0, 1) + toString(l-2) + s.substring(l-1, l)); 31 | // printf("%c%d%c\n",s[0],l-2,s[l-1]); 32 | else 33 | // printf("%s\n",s); 34 | println(s); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /codegen/e6.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 8 1 8 | 10 9 8 7 7 7 5 5 9 | === end === 10 | Output: 11 | === output === 12 | 1 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codeforces 158A #62259103 17 | */ 18 | #include 19 | int main() 20 | { 21 | int m,k,a[50],i; 22 | scanf("%d%d",&m,&k); 23 | for(i=0;i=a[k-1]&&a[i]&&i=a[k-1]&&a[i] > 0&&i 20 | int main(){ 21 | int n,x,y,z,c=0,k; 22 | scanf("%d",&n); 23 | for(k=0;k1)c++; 26 | } 27 | printf("%d\n",c); 28 | } -------------------------------------------------------------------------------- /codegen/e7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 2 8 | 1 0 0 9 | 1 1 1 10 | === end === 11 | Output: 12 | === output === 13 | 1 14 | === end === 15 | ExitCode: 0 16 | InstLimit: -1 17 | Origin Package: Codeforces 231A #46181712 18 | */ 19 | int n; 20 | int x; 21 | int y; 22 | int z; 23 | int c = 0; 24 | int k; 25 | int main(){ 26 | //int n,x,y,z,c=0,k; 27 | //scanf("%d",&n); 28 | n = getInt(); 29 | for(k=0;k1)c++; 35 | } 36 | printlnInt(c); 37 | //printf("%d\n",c); 38 | } -------------------------------------------------------------------------------- /codegen/e8.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 0 0 0 0 0 8 | 0 0 0 0 0 9 | 0 1 0 0 0 10 | 0 0 0 0 0 11 | 0 0 0 0 0 12 | === end === 13 | Output: 14 | === output === 15 | 1 16 | === end === 17 | ExitCode: 0 18 | InstLimit: -1 19 | Origin Package: Codeforces 263A #48540584 20 | */ 21 | #include 22 | 23 | int main() 24 | { 25 | int n,r,c,i,j; 26 | for (i=0;i<5;i++) 27 | for (j=0;j<5;j++) 28 | { 29 | scanf("%d", &n); 30 | if (n==1) 31 | {r=i;c=j;}} 32 | printf("%d",abs(2-r)+abs(2-c)); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /codegen/e8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 0 0 0 0 0 8 | 0 0 0 0 0 9 | 0 1 0 0 0 10 | 0 0 0 0 0 11 | 0 0 0 0 0 12 | === end === 13 | Output: 14 | === output === 15 | 1 16 | === end === 17 | ExitCode: 0 18 | InstLimit: -1 19 | Origin Package: Codeforces 263A #48540584 20 | */ 21 | int n; 22 | int r; 23 | int c; 24 | int i; 25 | int j; 26 | int abs(int c){ 27 | if(c>0) return c; 28 | return -c; 29 | } 30 | 31 | int main() 32 | { 33 | // int n,r,c,i,j; 34 | for (i=0;i<5;i++) 35 | for (j=0;j<5;j++) 36 | { 37 | n = getInt(); 38 | //scanf("%d", &n); 39 | if (n==1) 40 | {r=i;c=j;}} 41 | printInt(abs(2-r) + abs(2-c)); 42 | // printf("%d",abs(2-r)+abs(2-c)); 43 | return 0; 44 | } -------------------------------------------------------------------------------- /codegen/e9.c: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Pikachu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 3 8 | 4 1 7 9 | -2 4 -1 10 | 1 -5 -3 11 | === end === 12 | Output: 13 | === output === 14 | NO 15 | === end === 16 | ExitCode: 0 17 | InstLimit: -1 18 | Origin Package: Codeforces 69A #42823903 19 | */ 20 | #include 21 | int main(void) 22 | { int p,q,r,x=0,y=0,z=0,n,i; 23 | scanf("%d", &n); 24 | for(i=0;i= r) 39 | return; 40 | int q = partition(a, p, r); 41 | quick_sort(a, p, q - 1); 42 | quick_sort(a, q + 1, r); 43 | } 44 | 45 | void quick_sort_inf(int[] a) { 46 | quick_sort(a, 0, a.size() - 1); 47 | } 48 | 49 | int main() { 50 | int n = getInt(); 51 | int[] a = new int[n]; 52 | 53 | int i; 54 | for (i = 0; i < n; ++i) 55 | a[i] = getInt(); 56 | 57 | quick_sort_inf(a); 58 | 59 | for (i = 0; i < n; ++i) 60 | print(toString(a[i]) + " "); 61 | println(""); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /codegen/sorting/selection_sort.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Yunwei Ren 4 | Input: 5 | === input === 6 | 100 7 | 58 18 71 22 37 93 47 50 3 9 53 95 45 14 74 48 44 20 12 73 29 10 19 28 87 20 27 85 56 87 18 11 55 15 19 10 69 69 29 70 96 69 53 10 30 87 73 26 21 95 19 24 3 25 10 9 67 25 79 41 10 9 48 96 11 44 69 62 47 31 64 21 50 31 11 34 15 51 4 65 71 55 92 49 8 26 27 36 96 4 77 47 4 2 66 41 15 78 7 56 8 | 9 | === end === 10 | Output: 11 | === output === 12 | 2 3 3 4 4 4 7 8 9 9 9 10 10 10 10 10 11 11 11 12 14 15 15 15 18 18 19 19 19 20 20 21 21 22 24 25 25 26 26 27 27 28 29 29 30 31 31 34 36 37 41 41 44 44 45 47 47 47 48 48 49 50 50 51 53 53 55 55 56 56 58 62 64 65 66 67 69 69 69 69 70 71 71 73 73 74 77 78 79 85 87 87 87 92 93 95 95 96 96 96 13 | 14 | === end === 15 | ExitCode: 0 16 | InstLimit: -1 17 | */ 18 | 19 | void selection_sort(int[] a) { 20 | int i; 21 | int n = a.size(); 22 | for (i = 0; i < n - 1; ++i) { 23 | int min_pos = i; 24 | int j; 25 | for (j = i + 1; j < n; ++j) { 26 | if (a[j] < a[min_pos]) 27 | min_pos = j; 28 | } 29 | int t = a[i]; 30 | a[i] = a[min_pos]; 31 | a[min_pos] = t; 32 | } 33 | } 34 | 35 | int main() { 36 | int n = getInt(); 37 | int[] a = new int[n]; 38 | 39 | int i; 40 | for (i = 0; i < n; ++i) 41 | a[i] = getInt(); 42 | 43 | selection_sort(a); 44 | 45 | for (i = 0; i < n; ++i) 46 | print(toString(a[i]) + " "); 47 | println(""); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /codegen/t10.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 14' Shichao Xu 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 1 11 | 1029 12 | 171 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-534 17 | */ 18 | #include 19 | 20 | int gcd5(int x, int y); 21 | 22 | int gcd(int x, int y) { 23 | if (x%y == 0) return y; 24 | else return gcd5(y, x%y); 25 | } 26 | 27 | 28 | int gcd1(int x, int y) { 29 | if (x%y == 0) return y; 30 | else return gcd(y, x%y); 31 | } 32 | 33 | 34 | int gcd2(int x, int y) { 35 | if (x%y == 0) return y; 36 | else return gcd1(y, x%y); 37 | } 38 | 39 | 40 | 41 | int gcd3(int x, int y) { 42 | if (x%y == 0) return y; 43 | else return gcd2(y, x%y); 44 | } 45 | 46 | 47 | int gcd4(int x, int y) { 48 | if (x%y == 0) return y; 49 | else return gcd(y, x%y); 50 | } 51 | 52 | 53 | int gcd5(int x, int y) { 54 | if (x%y == 0) return y; 55 | else return gcd2(y, x%y); 56 | } 57 | 58 | int main() { 59 | printf("%d\n", (gcd(10,1))); 60 | printf("%d\n", (gcd(34986,3087))); 61 | printf("%d\n", (gcd(2907,1539))); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /codegen/t10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 14' Shichao Xu 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 1 11 | 1029 12 | 171 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-534 17 | */ 18 | 19 | int gcd(int x, int y) { 20 | if (x%y == 0) return y; 21 | else return gcd5(y, x%y); 22 | } 23 | 24 | 25 | int gcd1(int x, int y) { 26 | if (x%y == 0) return y; 27 | else return gcd(y, x%y); 28 | } 29 | 30 | 31 | int gcd2(int x, int y) { 32 | if (x%y == 0) return y; 33 | else return gcd1(y, x%y); 34 | } 35 | 36 | 37 | 38 | int gcd3(int x, int y) { 39 | if (x%y == 0) return y; 40 | else return gcd2(y, x%y); 41 | } 42 | 43 | 44 | int gcd4(int x, int y) { 45 | if (x%y == 0) return y; 46 | else return gcd(y, x%y); 47 | } 48 | 49 | 50 | int gcd5(int x, int y) { 51 | if (x%y == 0) return y; 52 | else return gcd2(y, x%y); 53 | } 54 | 55 | int main() { 56 | println(toString(gcd(10,1))); 57 | println(toString(gcd(34986,3087))); 58 | println(toString(gcd(2907,1539))); 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /codegen/t11.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 55 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-538 14 | */ 15 | 16 | int main() { 17 | int n = 10; 18 | int f0 = 0; 19 | int f1 = 1; 20 | int f2; 21 | int i; 22 | for (i = 1; i < n; ++i) { 23 | f2 = f0 + f1; 24 | f0 = f1; 25 | f1 = f2; 26 | } 27 | return f2; 28 | } -------------------------------------------------------------------------------- /codegen/t11.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 55 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-538 14 | */ 15 | 16 | int main() { 17 | int n = 10; 18 | int f0 = 0; 19 | int f1 = 1; 20 | int f2; 21 | int i; 22 | for (i = 1; i < n; ++i) { 23 | f2 = f0 + f1; 24 | f0 = f1; 25 | f1 = f2; 26 | } 27 | return f2; 28 | } -------------------------------------------------------------------------------- /codegen/t12.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 15' Yiran Wu 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | str1str2str3str4str5str6str7str8str9str10 11 | str1str2str3str4str5str6str7str8str9str10 12 | str1str2str3str4str5str6str7str8str9str10 13 | str1str2str3str4str5str6str7str8str9str10 14 | str1str2str3str4str5str6str7str8str9str10 15 | str1str2str3str4str5str6str7str8str9str10 16 | str1str2str3str4str5str6str7str8str9str10 17 | str1str2str3str4str5str6str7str8str9str10 18 | str1str2str3str4str5str6str7str8str9str10 19 | str1str2str3str4str5str6str7str8str9str10 20 | str1str2str3str4str5str6str7str8str9str10 21 | str1str2str3str4str5str6str7str8str9str10 22 | str1str2str3str4str5str6str7str8str9str10 23 | str1str2str3str4str5str6str7str8str9str10 24 | str1str2str3str4str5str6str7str8str9str10 25 | str1str2str3str4str5str6str7str8str9str10 26 | str1str2str3str4str5str6str7str8str9str10 27 | str1str2str3str4str5str6str7str8str9str10 28 | str1str2str3str4str5str6str7str8str9str10 29 | str1str2str3str4str5str6str7str8str9str10 30 | str1str2str3str4str5str6str7str8str9str10 31 | str1str2str3str4str5str6str7str8str9str10 32 | str1str2str3str4str5str6str7str8str9str10 33 | str1str2str3str4str5str6str7str8str9str10 34 | str1str2str3str4str5str6str7str8str9str10 35 | str1str2str3str4str5str6str7str8str9str10 36 | str1str2str3str4str5str6str7str8str9str10 37 | str1str2str3str4str5str6str7str8str9str10 38 | str1str2str3str4str5str6str7str8str9str10 39 | str1str2str3str4str5str6str7str8str9str10 40 | === end === 41 | ExitCode: 0 42 | InstLimit: -1 43 | Origin Package: Codegen Pretest-539 44 | */ 45 | 46 | int[][] a=new int[30][30]; 47 | string[] str=new string[30]; 48 | int main() 49 | { 50 | int i; 51 | int j; 52 | for(i=0;i<=29;i++) 53 | { 54 | int sum=0; 55 | str[i]=toString(a[i][0]); 56 | for(j=0;j 20 && i < 80) { 33 | for (j = 0;j < 100;j++) 34 | if (j > 5 || i < 90) { 35 | quotient = j * 4 / 100; 36 | remainder = j * 4 % 100; 37 | a[i + quotient][remainder] = j + (100 - 1 + 1 - 1 + 1) / 2; 38 | } 39 | } 40 | 41 | for (i = 0;i < 100;i++) 42 | for (j = 0;j < 100;j++) 43 | sum = sum + a[i][j]; 44 | println(toString(sum)); 45 | return 0; 46 | } -------------------------------------------------------------------------------- /codegen/t16.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 7053 11 | 1035 12 | 7035 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-544 17 | */ 18 | 19 | void foo(int d, int x, int y) { 20 | println(toString(d*1000 + x*10 + y)); 21 | if (d == 1) return; 22 | int t = x; x = y; y = t; 23 | foo(1, x, y); 24 | println(toString(d*1000 + x*10 + y)); 25 | } 26 | int main() { 27 | foo(7, 5, 3); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /codegen/t17.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 09' Xiao Jia 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 3141592653589793238462643383279528841971693993751058209749445923078164062862089986280348253421170679821480865132823664709384469555822317253594081284811174502841270193852115559644622948954930381964428810975665933446128475648233786783165271201991456485669234634861045432664821339360726024914127372458706606315588174881520920962829254917153643678925903611330530548820466521384146951941511609433057273657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566438602139494639522473719070217986943702770539217176293176752384674818467669451320005681271452635608277857713427577896091736371787214684409012249534301465495853710579227968925892354201995611212902196864344181598136297747713099605187072113499999983729780499510597317328160963185 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | Origin Package: Codegen Pretest-552 15 | */ 16 | #include 17 | 18 | int main() { 19 | int a = 10000; 20 | int b = 0; 21 | int c = 2800; 22 | int d = 0; 23 | int e = 0; 24 | int *f = new int[2801]; 25 | int g = 0; 26 | 27 | for (;b-c!=0;b++) 28 | f[b] = a/5; 29 | for (;; e = d%a){ 30 | d = 0; 31 | g = c*2; 32 | if (g==0) break; 33 | 34 | for (b=c;;d=d*b){ 35 | d=d+f[b]*a; 36 | f[b] = d%--g; 37 | d=d/g; 38 | g--; 39 | if (--b==0) break; 40 | } 41 | 42 | c = c-14; 43 | printf("%d", (e+d/a)); 44 | } 45 | 46 | printf("\n"); 47 | return 0; 48 | } -------------------------------------------------------------------------------- /codegen/t17.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 09' Xiao Jia 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 3141592653589793238462643383279528841971693993751058209749445923078164062862089986280348253421170679821480865132823664709384469555822317253594081284811174502841270193852115559644622948954930381964428810975665933446128475648233786783165271201991456485669234634861045432664821339360726024914127372458706606315588174881520920962829254917153643678925903611330530548820466521384146951941511609433057273657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566438602139494639522473719070217986943702770539217176293176752384674818467669451320005681271452635608277857713427577896091736371787214684409012249534301465495853710579227968925892354201995611212902196864344181598136297747713099605187072113499999983729780499510597317328160963185 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | Origin Package: Codegen Pretest-552 15 | */ 16 | 17 | int main() { 18 | int a = 10000; 19 | int b = 0; 20 | int c = 2800; 21 | int d = 0; 22 | int e = 0; 23 | int[] f = new int[2801]; 24 | int g = 0; 25 | 26 | for (;b-c!=0;b++) 27 | f[b] = a/5; 28 | for (;; e = d%a){ 29 | d = 0; 30 | g = c*2; 31 | if (g==0) break; 32 | 33 | for (b=c;;d=d*b){ 34 | d=d+f[b]*a; 35 | f[b] = d%--g; 36 | d=d/g; 37 | g--; 38 | if (--b==0) break; 39 | } 40 | 41 | c = c-14; 42 | print(toString(e+d/a)); 43 | } 44 | 45 | print("\n"); 46 | return 0; 47 | } -------------------------------------------------------------------------------- /codegen/t19.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Yuncong Hu 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 5 8 | 5 9 | ABCDE 10 | 1 11 | 2 12 | 3 13 | 4 14 | 5 15 | === end === 16 | Output: 17 | === output === 18 | 5 E 19 | 10 20 | === end === 21 | ExitCode: 0 22 | InstLimit: -1 23 | Origin Package: Codegen Pretest-556 24 | */ 25 | 26 | //考察点:section 9 函数,包括函数定义,内建函数 27 | //算法:斜堆 28 | //样例输入: 29 | //5 5 30 | //ABCDE 31 | //1 2 3 4 5 32 | //样例输出: 33 | //5 E 34 | //10 35 | int N; 36 | int M; 37 | string ch; 38 | 39 | int[] l; 40 | int[] r; 41 | int[] w; 42 | 43 | int merge(int x,int y) 44 | { 45 | if (0 == x) return y; 46 | if (0 == y) return x; 47 | if (w[x] < w[y]) { 48 | int e = x; 49 | x = y; 50 | y = e; 51 | } 52 | r[x] = merge(r[x],y); 53 | int e = l[x]; 54 | l[x] = r[x]; 55 | r[x] = e; 56 | return x; 57 | } 58 | 59 | int main() 60 | { 61 | N = getInt(); 62 | M = getInt(); 63 | ch = getString(); 64 | l = new int[N+M+5]; 65 | r = new int[N+M+5]; 66 | w = new int[N+M+5]; 67 | int i; 68 | for (i=1;i <= N;i++) { 69 | w[i] = getInt(); 70 | l[i] = 0; 71 | r[i] = 0; 72 | } 73 | for (i=1;i <= M;i++) { 74 | w[i + N] = ch.ord(i-1); 75 | l[i + N] = 0; 76 | r[i + N] = 0; 77 | } 78 | int rt0 = 1; 79 | int rt1 = N + 1; 80 | for (i = 2;i <= N;i++) 81 | rt0 = merge(rt0,i); 82 | for (i = N+2;i<= N+M;i++) 83 | rt1 = merge(rt1,i); 84 | print(toString(w[rt0])); 85 | print(" "); 86 | print(ch.substring(rt1-N-1,rt1-N)); 87 | print("\n"); 88 | println(toString(merge(rt0,rt1))); 89 | return 0; 90 | } -------------------------------------------------------------------------------- /codegen/t20.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 09' Xiao Jia 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 6 8 | === end === 9 | Output: 10 | === output === 11 | 720 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codegen Pretest-558 16 | */ 17 | //Target: use loops to calculate calculator of 6! 18 | //@author yixi 19 | 20 | int N; 21 | int h = 99; 22 | int i = 100; 23 | int j = 101; 24 | int k = 102; 25 | int total = 0; 26 | 27 | int main() { 28 | int a; 29 | int b; 30 | int c; 31 | int d; 32 | int e; 33 | int f; 34 | N=getInt(); 35 | for ( a=1; a<=N; a++ ) 36 | for ( b=1; b<=N; b++ ) 37 | for ( c=1; c<=N; c++ ) 38 | for ( d=1; d<=N; d++ ) 39 | for ( e=1; e<=N; e++ ) 40 | for ( f=1; f<=N; f++ ) 41 | if (a!=b && a!=c && a!=d && a!=e && a!=f && a!=h && a!=i && a!=j && a!=k 42 | && b!=c && b!=d && b!=e && b!=f && b!=h && b!=i && b!=j && b!=k 43 | && c!=d && c!=e && c!=f && c!=h && c!=i && c!=j && c!=k 44 | && d!=e && d!=f && d!=h && d!=i && d!=j && d!=k 45 | && e!=f && e!=h && e!=i && e!=j && e!=k 46 | && f!=h && f!=i && f!=j && f!=k && i!=j && h!=k) 47 | { 48 | total++; 49 | } 50 | 51 | println(toString(total)); 52 | return 0; 53 | } -------------------------------------------------------------------------------- /codegen/t22.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 10' Huan Yang 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 888 11 | 0 12 | 1 13 | 2 14 | 3 15 | 4 16 | 5 17 | 6 18 | 7 19 | 8 20 | 9 21 | 10 22 | 11 23 | 12 24 | 13 25 | 14 26 | 15 27 | 16 28 | 17 29 | 18 30 | 19 31 | 20 32 | 21 33 | 22 34 | 23 35 | 24 36 | 25 37 | 26 38 | 27 39 | 28 40 | 29 41 | 30 42 | 31 43 | 32 44 | 33 45 | 34 46 | 35 47 | 36 48 | 37 49 | 38 50 | 39 51 | 0 52 | -10 53 | -1 54 | === end === 55 | ExitCode: 0 56 | InstLimit: -1 57 | Origin Package: Codegen Pretest-560 58 | */ 59 | 60 | int[][] a = new int[4][]; 61 | int i; 62 | int j; 63 | 64 | class rec { 65 | int num; 66 | int c; 67 | }; 68 | 69 | rec[] b = new rec[5]; 70 | 71 | void printNum(int num) { 72 | println(toString(num)); 73 | } 74 | int main() { 75 | for (i = 0; i < 4; i++) { 76 | a[i] = new int[11]; 77 | } 78 | 79 | 80 | for (i = 0; i < 4; i ++) { 81 | for (j = 0; j < 10; j ++) 82 | a[i][j] = 888; 83 | } 84 | for (i = 0; i < 5; i ++) { 85 | b[i] = new rec; 86 | b[i].num = -1; 87 | } 88 | 89 | printNum(a[3][9]); 90 | for (i = 0; i <= 3; i ++) 91 | for (j = 0; j <= 9; j ++) 92 | a[i][j] = i * 10 + j; 93 | 94 | for (i = 0; i <= 3; i ++) 95 | for (j = 0; j <= 9; j ++) 96 | printNum(a[i][j]); 97 | a[2][10]=0; 98 | printNum(a[2][10]); 99 | b[0].num = -2; 100 | b[a[2][10]].num = -10; 101 | printNum(b[0].num); 102 | printNum(b[1].num); 103 | return 0; 104 | } -------------------------------------------------------------------------------- /codegen/t28.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 09' Xiao Jia 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 1 11 | 1029 12 | 171 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-567 17 | */ 18 | int gcd(int x, int y) { 19 | if (x%y == 0) return y; 20 | else return gcd(y, x%y); 21 | } 22 | 23 | int main() { 24 | println(toString(gcd(10,1))); 25 | println(toString(gcd(34986,3087))); 26 | println(toString(gcd(2907,1539))); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /codegen/t29.mx: -------------------------------------------------------------------------------- 1 | /* 2 | The same as t28.xm 3 | Test Package: Codegen 4 | Author: 09' Xiao Jia 5 | Time: 2020-02-02 6 | Input: 7 | === input === 8 | === end === 9 | Output: 10 | === output === 11 | 1 12 | 1029 13 | 171 14 | === end === 15 | ExitCode: 0 16 | InstLimit: -1 17 | Origin Package: Codegen Pretest-567 18 | */ 19 | int gcd(int x, int y) { 20 | if (x%y == 0) return y; 21 | else return gcd(y, x%y); 22 | } 23 | 24 | int main() { 25 | println(toString(gcd(10,1))); 26 | println(toString(gcd(34986,3087))); 27 | println(toString(gcd(2907,1539))); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /codegen/t3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 10' Huan Yang 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 103 8 | === end === 9 | Output: 10 | === output === 11 | 67 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codegen Pretest-525 16 | */ 17 | #include 18 | 19 | int N; 20 | int head; 21 | int startx; 22 | int starty; 23 | int targetx; 24 | int targety; 25 | int x; 26 | int y; 27 | int *xlist = new int[12000]; 28 | int *ylist = new int[12000]; 29 | int tail; 30 | int ok; 31 | int now; 32 | int *dx = new int[8]; 33 | int *dy = new int[9]; 34 | int **step; 35 | int i; 36 | int j; 37 | 38 | void origin(int N) 39 | { 40 | head = 0; 41 | tail = 0; 42 | step = new int*[N]; 43 | for (i = 0; i < N; i ++ ) { 44 | step[i] = new int[N]; 45 | for (j = 0; j < N; j ++ ) 46 | step[i][j] = 0; 47 | } 48 | } 49 | 50 | bool check(int a) { 51 | return ((a < N) && (a >= 0)); 52 | } 53 | 54 | void addList(int x, int y) { 55 | if (check(x) && check(y) && step[x][y] == -1) { 56 | tail ++; 57 | xlist[tail] = x; 58 | ylist[tail] = y; 59 | step[x][y] = now + 1; 60 | if ((x == targetx) && (y == targety)) ok = 1; 61 | } 62 | } 63 | int main() { 64 | origin(106); 65 | scanf("%d", &N); 66 | // N = getInt(); 67 | targety = N - 1; 68 | targetx = targety; 69 | for (i = 0; i < N; i ++) 70 | for (j = 0; j < N; j ++) 71 | step[i][j] = -1; 72 | dx[0] = -2; dy[0] = -1; 73 | dx[1] = -2; dy[1] = 1; 74 | dx[2] = 2; dy[2] = -1; 75 | dx[3] = 2; dy[3] = 1; 76 | dx[4] = -1; dy[4] = -2; 77 | dx[5] = -1; dy[5] = 2; 78 | dx[6] = 1; dy[6] = -2; 79 | dx[7] = 1; dy[7] = 2; 80 | while (head <= tail) { 81 | x = xlist[head]; 82 | y = ylist[head]; 83 | now = step[x][y]; 84 | for (j = 0;j < 8;j ++) 85 | addList(x + dx[j], y + dy[j]); 86 | if (ok == 1) break; 87 | head ++; 88 | } 89 | if (ok == 1) printf("%d\n", (step[targetx][targety])); 90 | else printf("no solution!\n"); 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /codegen/t3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 10' Huan Yang 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 103 8 | === end === 9 | Output: 10 | === output === 11 | 67 12 | === end === 13 | ExitCode: 0 14 | InstLimit: -1 15 | Origin Package: Codegen Pretest-525 16 | */ 17 | 18 | int N; 19 | int head; 20 | int startx; 21 | int starty; 22 | int targetx; 23 | int targety; 24 | int x; 25 | int y; 26 | int[] xlist = new int[12000]; 27 | int[] ylist = new int[12000]; 28 | int tail; 29 | int ok; 30 | int now; 31 | int[] dx = new int[8]; 32 | int[] dy = new int[9]; 33 | int[][] step; 34 | int i; 35 | int j; 36 | 37 | void origin(int N) 38 | { 39 | head = 0; 40 | tail = 0; 41 | step = new int[N][]; 42 | for (i = 0; i < N; i ++ ) { 43 | step[i] = new int[N]; 44 | for (j = 0; j < N; j ++ ) 45 | step[i][j] = 0; 46 | } 47 | } 48 | 49 | bool check(int a) { 50 | return ((a < N) && (a >= 0)); 51 | } 52 | 53 | void addList(int x, int y) { 54 | if (check(x) && check(y) && step[x][y] == -1) { 55 | tail ++; 56 | xlist[tail] = x; 57 | ylist[tail] = y; 58 | step[x][y] = now + 1; 59 | if ((x == targetx) && (y == targety)) ok = 1; 60 | } 61 | } 62 | int main() { 63 | origin(106); 64 | N = getInt(); 65 | targety = N - 1; 66 | targetx = targety; 67 | for (i = 0; i < N; i ++) 68 | for (j = 0; j < N; j ++) 69 | step[i][j] = -1; 70 | dx[0] = -2; dy[0] = -1; 71 | dx[1] = -2; dy[1] = 1; 72 | dx[2] = 2; dy[2] = -1; 73 | dx[3] = 2; dy[3] = 1; 74 | dx[4] = -1; dy[4] = -2; 75 | dx[5] = -1; dy[5] = 2; 76 | dx[6] = 1; dy[6] = -2; 77 | dx[7] = 1; dy[7] = 2; 78 | while (head <= tail) { 79 | x = xlist[head]; 80 | y = ylist[head]; 81 | now = step[x][y]; 82 | for (j = 0;j < 8;j ++) 83 | addList(x + dx[j], y + dy[j]); 84 | if (ok == 1) break; 85 | head ++; 86 | } 87 | if (ok == 1) println(toString(step[targetx][targety])); 88 | else print("no solution!\n"); 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /codegen/t30.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 09' Xiao Jia 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | 18 8 | 12 9 | 6 10 | === end === 11 | Output: 12 | === output === 13 | 13 14 | === end === 15 | ExitCode: 0 16 | InstLimit: -1 17 | Origin Package: Codegen Pretest-568 18 | */ 19 | 20 | int tak(int x, int y, int z) { 21 | if ( y < x ) return 1 + tak( tak(x-1, y, z), tak(y-1, z, x), tak(z-1, x, y) ); 22 | else return z; 23 | } 24 | 25 | int main(){ 26 | int a; 27 | int b; 28 | int c; 29 | a=getInt(); 30 | b=getInt(); 31 | c=getInt(); 32 | println(toString(tak(a,b,c))); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /codegen/t33.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 15 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-573 14 | */ 15 | int main() { 16 | int a = 5; 17 | int b; 18 | b = a; 19 | int c = a * 2 + b; 20 | return c; 21 | } -------------------------------------------------------------------------------- /codegen/t34.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 106 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-571 14 | */ 15 | int main() { 16 | string s1 = "aaa"; 17 | string s2 = "bbbbb"; 18 | string s3 = s1 + s2; 19 | return s3.length() + s3.ord(5); 20 | } -------------------------------------------------------------------------------- /codegen/t35.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 20 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-572 14 | */ 15 | int main() { 16 | int x = 10; 17 | int y = x; 18 | if (x == 10) { 19 | int x = 20; 20 | y = x; 21 | } 22 | return y; 23 | } -------------------------------------------------------------------------------- /codegen/t36.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 70 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-574 14 | */ 15 | class C2 { 16 | int x; 17 | int y; 18 | int z; 19 | }; 20 | 21 | int main() { 22 | C2 obj = new C2; 23 | obj.x = 10; 24 | obj.y = 20; 25 | obj.z = 40; 26 | return obj.x + obj.y + obj.z; 27 | } 28 | -------------------------------------------------------------------------------- /codegen/t37.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 0 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-575 14 | */ 15 | int main() { 16 | int[] a; 17 | int[] b = new int[10]; 18 | int[][] c = new int [2][]; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /codegen/t38.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 210 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-576 14 | */ 15 | int main() { 16 | int n = 20; 17 | int sum = 0; 18 | int i = 1; 19 | while (i <= n) { 20 | sum = sum + i; 21 | i = i+1; 22 | } 23 | return sum; 24 | } 25 | -------------------------------------------------------------------------------- /codegen/t39.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 10 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-577 14 | */ 15 | int min(int a, int b) { 16 | if (a <= b) return a; 17 | return b; 18 | } 19 | 20 | int main() { 21 | int x = 10; 22 | int y = 20; 23 | return min(x, y); 24 | } 25 | -------------------------------------------------------------------------------- /codegen/t40.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 20 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-578 14 | */ 15 | int main() { 16 | int[] a = new int[20]; 17 | return a.size(); 18 | } -------------------------------------------------------------------------------- /codegen/t41.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 110 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-579 14 | */ 15 | class C2 { 16 | int x; 17 | int y; 18 | bool b; 19 | int z; 20 | }; 21 | 22 | int main() { 23 | C2 obj = new C2; 24 | obj.x = 10; 25 | obj.y = 20; 26 | obj.b = obj.x > obj.y; 27 | if (obj.b) obj.z = 40; 28 | else obj.z = 80; 29 | return obj.x + obj.y + obj.z; 30 | } -------------------------------------------------------------------------------- /codegen/t42.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 20 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-580 14 | */ 15 | class C1 { 16 | int x; 17 | }; 18 | 19 | int main() { 20 | C1 c1 = new C1; 21 | c1.x = 10; 22 | return 2 * c1.x; 23 | } -------------------------------------------------------------------------------- /codegen/t43.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 20 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-581 14 | */ 15 | int main() { 16 | int x = 10; 17 | if (x == 10) x = 20; 18 | else x = 30; 19 | return x; 20 | } -------------------------------------------------------------------------------- /codegen/t44.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 13 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-582 14 | */ 15 | int tak(int x, int y, int z) { 16 | if(y < x) { 17 | return 1 + tak( tak(x - 1, y , z), 18 | tak(y - 1, z , x), 19 | tak(z - 1, x , y) 20 | ); 21 | } else { 22 | return z; 23 | } 24 | } 25 | 26 | int main() { 27 | return tak(18,12,6); 28 | } -------------------------------------------------------------------------------- /codegen/t45.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 30 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-583 14 | */ 15 | int main() { 16 | int[] a = new int[1]; 17 | a[0] = 10; 18 | return a[0] + 20; 19 | } 20 | -------------------------------------------------------------------------------- /codegen/t46.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 75 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-584 14 | */ 15 | int main() { 16 | int n = 5; 17 | int sum = 0; 18 | int i; 19 | int j; 20 | for (i = 1; i <= n; ++i) 21 | for (j = 1; j <= n; ++j) 22 | sum = sum + i; 23 | return sum; 24 | } -------------------------------------------------------------------------------- /codegen/t47.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 30 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-585 14 | */ 15 | int main() { 16 | int a = 5; 17 | int b = 0; 18 | int c; 19 | if (b != 0 && a/b != 1) { 20 | c = 10; 21 | } else { 22 | c = 20; 23 | } 24 | 25 | if (!(c == 10 && a/b == 0 && a == 5)) 26 | c = 30; 27 | 28 | return c; 29 | } -------------------------------------------------------------------------------- /codegen/t48.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 20 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-586 14 | */ 15 | int x = 10; 16 | int main() { 17 | x = 20; 18 | return x; 19 | } 20 | -------------------------------------------------------------------------------- /codegen/t49.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 2 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-587-Modifiy 14 | */ 15 | int main() { 16 | string s = "hahaha"; 17 | return s.substring(2, 4).length(); 18 | } -------------------------------------------------------------------------------- /codegen/t5.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 16 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-528 14 | */ 15 | 16 | int main() { 17 | int a = 5; 18 | int b; 19 | int c; 20 | c = a++; 21 | b = c; 22 | return b+c+a; 23 | } -------------------------------------------------------------------------------- /codegen/t5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 16 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-528 14 | */ 15 | 16 | int main() { 17 | int a = 5; 18 | int b; 19 | int c; 20 | c = a++; 21 | b = c; 22 | return b+c+a; 23 | } -------------------------------------------------------------------------------- /codegen/t50.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 210 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-588 14 | */ 15 | int main() { 16 | int n = 10; 17 | int sum = 0; 18 | int i; 19 | for (i = 1; i <= n; ++i) sum = sum + i; 20 | int j; 21 | for (j = 1; j <= n; ++j) sum = sum + 10 + j; 22 | return sum; 23 | } 24 | -------------------------------------------------------------------------------- /codegen/t51.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 80 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-590 14 | */ 15 | int main() { 16 | int n = 5; 17 | int sum = 0; 18 | int i; 19 | int j; 20 | for (i = 1; i <= n; ++i) { 21 | for (j = 1; j <= n; ++j) 22 | sum = sum + i; 23 | sum = sum + 1; 24 | } 25 | return sum; 26 | } -------------------------------------------------------------------------------- /codegen/t52.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 15 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-591 14 | */ 15 | int main() { 16 | int la = 5; 17 | int[] a = new int[la]; 18 | 19 | int cnt = 0; 20 | int i; 21 | for (i = 0; i < la; ++i) 22 | a[i] = ++cnt; 23 | 24 | int sum = 0; 25 | for (i = 0; i < la; ++i) sum = sum + a[i]; 26 | 27 | return sum; 28 | } 29 | -------------------------------------------------------------------------------- /codegen/t53.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 120 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-592 14 | */ 15 | int main() { 16 | int la = 5; 17 | int lb = 10; 18 | int[] a; 19 | int[] b = new int[lb]; 20 | int[][] c = new int [2][]; 21 | a = new int[la]; 22 | c[0] = a; 23 | c[1] = b; 24 | 25 | int cnt = 0; 26 | int i; 27 | int j; 28 | for (i = 0; i < 2; ++i) 29 | for (j = 0; j < la; ++j) 30 | c[i][j] = ++cnt; 31 | for (j = la; j < lb; ++j) 32 | c[1][j] = ++cnt; 33 | 34 | int sum = 0; 35 | for (i = 0; i < la; ++i) sum = sum + a[i]; 36 | for (i = 0; i < lb; ++i) sum = sum + b[i]; 37 | 38 | return sum; 39 | } 40 | -------------------------------------------------------------------------------- /codegen/t54.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-02 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 30 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-593 14 | */ 15 | int main() { 16 | int a = 5; 17 | int b = 0; 18 | int c; 19 | bool d = b != 0 && a/b != 1; 20 | if (d) { 21 | c = 10; 22 | } else { 23 | c = 20; 24 | } 25 | 26 | bool e; 27 | e = !(c == 10 && a/b == 0 && a == 5); 28 | if (e) 29 | c = 30; 30 | 31 | return c; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /codegen/t57.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 15' Bowen Tan 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 989898987 8 | === end === 9 | Output: 10 | === output === 11 | 3 12 | 989898983 2 2 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-871 17 | */ 18 | int n; 19 | 20 | void init() { 21 | n = getInt(); 22 | } 23 | 24 | bool is_prime(int x) { 25 | if (x == 1) { 26 | return false; 27 | } 28 | int i; 29 | for (i = 2; i * i <= x; i ++) { 30 | if (x % i == 0) { 31 | return false; 32 | } 33 | } 34 | return true; 35 | } 36 | 37 | void find(int x, int pre) { 38 | if (is_prime(x)) { 39 | if (pre > 0) { 40 | //printf("2\n"); 41 | println("2"); 42 | //printf("%d %d\n", pre, x); 43 | println(toString(pre) + " " + toString(x)); 44 | } else { 45 | //printf("1\n%d\n", x); 46 | println("1"); 47 | println(toString(x)); 48 | } 49 | return ; 50 | } 51 | int i = 5; 52 | if (pre == -1) { 53 | int i = 6; 54 | for (i = x - 2; ; i --) { 55 | if (is_prime(i)) { 56 | find(x - i, i); 57 | return ; 58 | } 59 | } 60 | } else { 61 | for (i = x - 1; ; i --) { 62 | if (is_prime(i) && is_prime(x - i)) { 63 | //printf("3\n%d %d %d\n", pre, i, x - i); 64 | println("3"); 65 | println(toString(pre) + " " + toString(i) + " " + toString(x - i)); 66 | return ; 67 | } 68 | } 69 | } 70 | } 71 | 72 | void work() { 73 | find(n, -1); 74 | } 75 | 76 | int main() { 77 | 78 | init(); 79 | work(); 80 | 81 | return 0; 82 | } -------------------------------------------------------------------------------- /codegen/t59.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 14' Rongyu You 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 100 100000 8 | 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 9 | === end === 10 | Output: 11 | === output === 12 | 284456 13 | === end === 14 | ExitCode: 0 15 | InstLimit: -1 16 | Origin Package: Codegen Pretest-873 17 | */ 18 | // USACO 3.1.3 humble 19 | int MAXK = 105; 20 | int MAXN = 100005; 21 | 22 | int main(){ 23 | int point = 0; 24 | int k; 25 | int MIN; 26 | int K; 27 | int N; 28 | int i; 29 | int[] primes = new int[MAXK]; 30 | int[] pindex = new int[MAXK]; 31 | int[] ans = new int[MAXN]; 32 | K = getInt(); 33 | N = getInt(); 34 | for (i = 0; i < K; ++i) { 35 | primes[i] = getInt(); 36 | pindex[i] = 0; 37 | } 38 | ans[0] = 1; 39 | while(point <= N){ 40 | MIN = 2139062143; 41 | for (i = 0 ; i < K; ++i){ 42 | while(ans[point] >= primes[i] * ans[pindex[i]]) pindex[i]++; 43 | if (primes[i] * ans[pindex[i]] < MIN){ 44 | MIN = primes[i] * ans[pindex[i]]; 45 | k = i; 46 | } 47 | } 48 | ans[++point] = MIN; 49 | } 50 | print(toString(ans[N])); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /codegen/t6.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 16 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-529 14 | */ 15 | 16 | int main() { 17 | int a = 5; 18 | int b; 19 | int c; 20 | c = a++; 21 | b = c; 22 | return a; 23 | } -------------------------------------------------------------------------------- /codegen/t6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 6 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-529 14 | */ 15 | 16 | int main() { 17 | int a = 5; 18 | int b; 19 | int c; 20 | c = a++; 21 | b = c; 22 | return a; 23 | } -------------------------------------------------------------------------------- /codegen/t60.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 15' Haoran Ye 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | eternal! 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | Origin Package: Codegen Pretest-876 15 | */ 16 | class older{ 17 | int age; 18 | void solveAge(){ 19 | int i; 20 | int j; 21 | int k; 22 | for(i = 1; i < 100; i++) 23 | for(j = i + 1; j < 100; j++) 24 | for(k = j + 1; k < 100; k++) 25 | if((i - i + i + j - j + j + k - k + k) * (100 * i + 10 * j + k) % 1926 == 0) age = (i - i + i + j - j + j + k - k + k) * (100 * i + 10 * j + k); 26 | } 27 | }; 28 | int main(){ 29 | older mrJiang = new older; 30 | mrJiang.solveAge(); 31 | if(mrJiang.age > 10000)println("eternal!"); 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /codegen/t62.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Admin 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 30 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-901 14 | */ 15 | int x; 16 | int y; 17 | int main() { 18 | x = 10; 19 | y = 20; 20 | int c = x+y; 21 | return c; 22 | } 23 | -------------------------------------------------------------------------------- /codegen/t66.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 16' Zihan Zhou 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | === end === 11 | ExitCode: 124 12 | InstLimit: -1 13 | Origin Package: Codegen Pretest-946 14 | */ 15 | 16 | int lol (int x) { 17 | return x + 1; 18 | } 19 | 20 | int c = 123; 21 | int x = lol(c); 22 | int main () { 23 | return x; 24 | } 25 | -------------------------------------------------------------------------------- /codegen/t68.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 16' Yuxi Liu 4 | Time: 2020-02-03 5 | Input: 6 | === input === 7 | 10 8 | === end === 9 | Output: 10 | === output === 11 | 1 12 | 2 13 | 2 14 | 4 15 | 2 16 | 6 17 | 4 18 | 6 19 | 4 20 | === end === 21 | ExitCode: 0 22 | InstLimit: -1 23 | Origin Package: Codegen Pretest-947 24 | */ 25 | 26 | //考察点:section 8 语句,包括if,while,for,break,continue,return等 27 | //算法:线性筛法求欧拉函数 28 | //样例输入:10 29 | //样例输出: 30 | //1 31 | //2 32 | //2 33 | //4 34 | //2 35 | //6 36 | //4 37 | //6 38 | //4 39 | 40 | int N; 41 | int M = 0; 42 | bool[] check; 43 | 44 | int main() { 45 | N = getInt(); 46 | check = new bool[N+5]; 47 | int i = 0; 48 | while ( i <= N ) check[i++] = true; 49 | int[] phi = new int[N+5]; 50 | int[] P = new int[N+5]; 51 | phi[1] = 1; 52 | for (i = 2; ; ++i ) { 53 | if ( i > N ) break; 54 | if ( check[i] ) { 55 | P[++M] = i; 56 | phi[i] = i - 1; 57 | } 58 | int k = i; 59 | int i; 60 | for (i = 1; i <= M && (k * P[i] <= N); i++) { 61 | int tmp = k * P[i]; 62 | if ( tmp > N ) continue; 63 | check[tmp] = false; 64 | if ( k % P[i] == 0) { 65 | phi[tmp] = phi[k] * P[i]; 66 | break; 67 | } 68 | else { 69 | phi[k * P[i]] = phi[k] * (P[i] - 1); 70 | } 71 | } 72 | println(toString(phi[k])); 73 | } 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /codegen/t69.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: YifanXu 4 | Time: 2020-04-09 5 | Input: 6 | === input === 7 | 4 5 8 | 1 2 2 9 | 1 3 2 10 | 1 4 3 11 | 2 3 4 12 | 3 4 3 13 | === end === 14 | Output: 15 | === output === 16 | 7 17 | === end === 18 | ExitCode: 0 19 | InstLimit: -1 20 | */ 21 | 22 | class Edge { 23 | int x; 24 | int y; 25 | int nxt; 26 | int w; 27 | }; 28 | 29 | int MAX = 1000000; 30 | int n; 31 | int m; 32 | int tot = 0; 33 | int ans = 0; 34 | 35 | int[] pick; 36 | int[] fst; 37 | int[] dis; 38 | 39 | Edge[] ed; 40 | 41 | void addedge(int x, int y, int w) { 42 | ++tot; 43 | ed[tot] = new Edge; 44 | ed[tot].x = x; 45 | ed[tot].y = y; 46 | ed[tot].w = w; 47 | ed[tot].nxt = fst[x]; 48 | fst[x] = tot; 49 | } 50 | 51 | int main() { 52 | n = getInt(); 53 | m = getInt(); 54 | pick = new int[n + 1]; 55 | fst = new int[n + 1]; 56 | dis = new int[n + 1]; 57 | ed = new Edge[2 * m + 1]; 58 | int i; 59 | for (i = 0; i <= n; ++i) { 60 | pick[i] = 0; 61 | fst[i] = 0; 62 | dis[i] = MAX; 63 | } 64 | int x; 65 | int y; 66 | int w; 67 | for (i = 1; i <= m; ++i) { 68 | x = getInt(); 69 | y = getInt(); 70 | w = getInt(); 71 | addedge(x, y, w); 72 | addedge(y, x, w); 73 | } 74 | x = 1; 75 | for (i = 1; i <= n - 1; ++i) { 76 | pick[x] = 1; 77 | int j; 78 | for (j = fst[x]; j != 0; j = ed[j].nxt) { 79 | int y = ed[j].y; 80 | 81 | if (pick[y] == 0 && ed[j].w < dis[y]) { 82 | dis[y] = ed[j].w; 83 | } 84 | } 85 | x = 0; 86 | for (j = 1; j <= n; ++j) { 87 | if (pick[j] == 0 && dis[j] < dis[x]) { 88 | x = j; 89 | } 90 | } 91 | if (x == 0) { 92 | printInt(-1); 93 | return 0; 94 | } 95 | ans = ans + dis[x]; 96 | 97 | } 98 | printInt(ans); 99 | return 0; 100 | } -------------------------------------------------------------------------------- /codegen/t7.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Haojun Mao 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 1 8 | 2 9 | 3 10 | 4 11 | === end === 12 | Output: 13 | === output === 14 | 0000 15 | 1234 16 | === end === 17 | ExitCode: 0 18 | InstLimit: -1 19 | Origin Package: Codegen Pretest-531 20 | */ 21 | //input: 1 2 3 4 22 | #include 23 | int *a = new int[4]; 24 | int main() 25 | { 26 | int *b = new int[4]; 27 | int i; 28 | for (i = 0; i < 4; i++) 29 | { 30 | a[i] = 0; 31 | scanf("%d", &b[i]); 32 | // b[i] = getInt(); 33 | } 34 | for (i = 0; i < 4; i++) 35 | { 36 | printf("%d", (a[i])); 37 | } 38 | printf("\n"); 39 | a=b; 40 | for (i = 0; i < 4; i++) 41 | { 42 | printf("%d", (a[i])); 43 | } 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /codegen/t7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Haojun Mao 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 1 8 | 2 9 | 3 10 | 4 11 | === end === 12 | Output: 13 | === output === 14 | 0000 15 | 1234 16 | === end === 17 | ExitCode: 0 18 | InstLimit: -1 19 | Origin Package: Codegen Pretest-531 20 | */ 21 | //input: 1 2 3 4 22 | 23 | int[] a = new int[4]; 24 | int main() 25 | { 26 | int[] b = new int[a.size()]; 27 | int i; 28 | for (i = 0; i < a.size(); i++) 29 | { 30 | a[i] = 0; 31 | b[i] = getInt(); 32 | } 33 | for (i = 0; i < a.size(); i++) 34 | { 35 | print(toString(a[i])); 36 | } 37 | println(""); 38 | a=b; 39 | for (i = 0; i < a.size(); i++) 40 | { 41 | print(toString(a[i])); 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /codegen/t8.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Haojun Mao 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 1 8 | 2 9 | 3 10 | 4 11 | === end === 12 | Output: 13 | === output === 14 | 4 15 | 1234 16 | 0000 17 | === end === 18 | ExitCode: 0 19 | InstLimit: -1 20 | Origin Package: Codegen Pretest-532 21 | */ 22 | // input: 1 2 3 4 23 | #include 24 | int *a = new int[4]; 25 | int main() 26 | { 27 | int **b = new int*[4]; 28 | int i; 29 | b[0] = a; 30 | b[1] = a; 31 | b[2] = a; 32 | b[3] = a; 33 | printf("%d\n", (4)); 34 | for (i = 0; i < 4; i++) 35 | scanf("%d", &b[0][i]); 36 | // b[0][i] = getInt(); 37 | for (i = 0; i < 4; i++) 38 | printf("%d", (b[1][i])); 39 | printf("\n"); 40 | for (i = 0; i < 4; i++) 41 | b[2][i] = 0; 42 | for (i = 0; i < 4; i++) 43 | printf("%d", (b[3][i])); 44 | return 0; 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /codegen/t8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Haojun Mao 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | 1 8 | 2 9 | 3 10 | 4 11 | === end === 12 | Output: 13 | === output === 14 | 4 15 | 1234 16 | 0000 17 | === end === 18 | ExitCode: 0 19 | InstLimit: -1 20 | Origin Package: Codegen Pretest-532 21 | */ 22 | // input: 1 2 3 4 23 | 24 | int[] a = new int[4]; 25 | int main() 26 | { 27 | int[][] b = new int[4][]; 28 | int i; 29 | b[0] = a; 30 | b[1] = a; 31 | b[2] = a; 32 | b[3] = a; 33 | println(toString(b.size())); 34 | for (i = 0; i < b[0].size(); i++) 35 | b[0][i] = getInt(); 36 | for (i = 0; i < b[1].size(); i++) 37 | print(toString(b[1][i])); 38 | println(""); 39 | for (i = 0; i < b[2].size(); i++) 40 | b[2][i] = 0; 41 | for (i = 0; i < b[3].size(); i++) 42 | print(toString(b[3][i])); 43 | return 0; 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /codegen/t9.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 14' Shichao Xu 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 1024 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | Origin Package: Codegen Pretest-533 15 | */ 16 | #include 17 | int qpow(int a,int p,int mod) { 18 | int t = 1; 19 | int y = a; 20 | while(p>0){ 21 | if((p&1) == 1)t=t*y % mod; 22 | y=y*y % mod; 23 | p=p / 2; 24 | } 25 | return t; 26 | } 27 | 28 | int main() { 29 | printf("%d\n", (qpow(2,10,10000))); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /codegen/t9.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: 14' Shichao Xu 4 | Time: 2020-01-25 5 | Input: 6 | === input === 7 | === end === 8 | Output: 9 | === output === 10 | 1024 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | Origin Package: Codegen Pretest-533 15 | */ 16 | int qpow(int a,int p,int mod) { 17 | int t = 1; 18 | int y = a; 19 | while(p>0){ 20 | if((p&1) == 1)t=t*y % mod; 21 | y=y*y % mod; 22 | p=p / 2; 23 | } 24 | return t; 25 | } 26 | 27 | 28 | 29 | 30 | 31 | int main() { 32 | println(toString(qpow(2,10,10000))); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /codegen2/shortest_path/edge_list.mh: -------------------------------------------------------------------------------- 1 | class Edge { 2 | int from; 3 | int to; 4 | int weight; 5 | }; 6 | 7 | class EdgeList { 8 | void init(int n, int m) { 9 | edges = new Edge[m]; 10 | next = new int[m]; 11 | first = new int[n]; 12 | int i; 13 | for (i = 0; i < m; ++i) 14 | next[i] = -1; 15 | for (i = 0; i < n; ++i) 16 | first[i] = -1; 17 | size = 0; 18 | } 19 | 20 | void addEdge(int u, int v, int w) { 21 | Edge e = new Edge(); 22 | e.from = u; 23 | e.to = v; 24 | e.weight = w; 25 | 26 | edges[size] = e; 27 | next[size] = first[u]; 28 | first[u] = size; 29 | ++size; 30 | } 31 | 32 | int nVertices() { 33 | return first.size(); 34 | } 35 | 36 | int nEdges() { 37 | return edges.size(); 38 | } 39 | 40 | 41 | Edge[] edges; 42 | int[] next; 43 | int[] first; 44 | int size; 45 | }; 46 | -------------------------------------------------------------------------------- /codegen2/shortest_path/floyd.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input shortest_path.1.in 5 | //#output shortest_path.1.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | // input: 11 | // n m 12 | // u_1 v_1 w_1 13 | // .... 14 | // u_m v_m w_m 15 | // (1 <= w_m <= 100) 16 | 17 | int INF = 10000000; 18 | int n; 19 | int m; 20 | int[][] a; 21 | 22 | void init() { 23 | n = getInt(); 24 | m = getInt(); 25 | a = new int[n][n]; 26 | 27 | int i; 28 | int j; 29 | for (i = 0; i < n; ++i) { 30 | for (j = 0; j < n; ++j) { 31 | a[i][j] = INF; 32 | } 33 | } 34 | for (i = 0; i < n; ++i) 35 | a[i][i] = 0; 36 | 37 | for (i = 0; i < m; ++i) { 38 | int u = getInt(); 39 | int v = getInt(); 40 | int w = getInt(); 41 | a[u][v] = w; 42 | } 43 | } 44 | 45 | int main() { 46 | init(); 47 | 48 | int i; 49 | int j; 50 | int k; 51 | for (k = 0; k < n; ++k) { 52 | for (i = 0; i < n; ++i) { 53 | for (j = 0; j < n; ++j) { 54 | if (a[i][j] > a[i][k] + a[k][j]) 55 | a[i][j] = a[i][k] + a[k][j]; 56 | } 57 | } 58 | } 59 | 60 | for (i = 0; i < n; ++i) { 61 | for (j = 0; j < n; ++j) { 62 | if (a[i][j] == INF) { 63 | print("-1"); 64 | } else { 65 | print(toString(a[i][j])); 66 | } 67 | print(" "); 68 | } 69 | println(""); 70 | } 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /codegen2/shortest_path/gen_data.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | INF = 2 ** 30 5 | 6 | 7 | def random_graph(n, p, low=1, high=1000): 8 | """ 9 | Generate a random simple graph where the weight of each edge is in [1, 100] 10 | 11 | :param n: The number of vertices 12 | :param p: The probability an edge presents 13 | :return: A list of edges. Each edge is a triple (from, to, weight) 14 | """ 15 | adj = np.random.rand(n, n) 16 | adj = (adj < p).astype(int) 17 | weights = low + (high - low) * np.random.rand(n, n) 18 | edges = [] 19 | for u in range(n): 20 | for v in range(n): 21 | if u == v or not adj[u][v]: 22 | continue 23 | edges.append((u, v, weights[u][v])) 24 | return edges 25 | 26 | 27 | def floyd(n, edges): 28 | dist = np.ones([n, n], dtype=np.int64) 29 | dist -= np.diag(np.ones(n, dtype=np.int64)) 30 | dist *= INF 31 | for u, v, w in edges: 32 | dist[u][v] = w 33 | 34 | for k in range(n): 35 | for i in range(n): 36 | for j in range(n): 37 | if dist[i][j] > dist[i][k] + dist[k][j]: 38 | dist[i][j] = dist[i][k] + dist[k][j] 39 | return dist 40 | 41 | 42 | def main(): 43 | n = 100 44 | p = 0.2 45 | edges = random_graph(n, p) 46 | with open("shortest_path.in", "w") as f: 47 | f.write("%d %d\n" % (n, len(edges))) 48 | for u, v, w in edges: 49 | f.write("%d %d %d\n" % (u, v, w)) 50 | 51 | dist = floyd(n, edges) 52 | with open("shortest_path.ans", "w") as f: 53 | for u in range(n): 54 | for v in range(n): 55 | f.write("%d " % (dist[u][v] if dist[u][v] != INF else -1)) 56 | f.write("\n") 57 | 58 | 59 | if __name__ == '__main__': 60 | main() 61 | -------------------------------------------------------------------------------- /codegen2/shortest_path/shortest_path.0.ans: -------------------------------------------------------------------------------- 1 | 0 126 -1 72 149 2 | -1 0 -1 -1 76 3 | 53 179 0 125 70 4 | -1 54 -1 0 77 5 | -1 -1 -1 -1 0 6 | -------------------------------------------------------------------------------- /codegen2/shortest_path/shortest_path.0.in: -------------------------------------------------------------------------------- 1 | 5 6 2 | 3 1 54 3 | 2 4 70 4 | 1 4 76 5 | 3 4 77 6 | 0 3 72 7 | 2 0 53 -------------------------------------------------------------------------------- /codegen2/shortest_path/spfa.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input shortest_path.1.in 5 | //#output shortest_path.1.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | //#include ../std/queue.mh TYPE:int 11 | //#include edge_list.mh 12 | 13 | int n; 14 | int m; 15 | EdgeList g; 16 | int INF = 10000000; 17 | 18 | void init() { 19 | n = getInt(); 20 | m = getInt(); 21 | g = new EdgeList(); 22 | g.init(n, m); 23 | 24 | int i; 25 | for (i = 0; i < m; ++i) { 26 | int u = getInt(); 27 | int v = getInt(); 28 | int w = getInt(); 29 | g.addEdge(u, v, w); 30 | } 31 | } 32 | 33 | int[] spfa(int s) { 34 | int[] d = new int[n]; 35 | int i; 36 | for (i = 0; i < n; ++i) { 37 | d[i] = INF; 38 | } 39 | d[s] = 0; 40 | 41 | Queue_int q = new Queue_int(); 42 | q.push(s); 43 | while (q.size() != 0) { 44 | int u = q.pop(); 45 | int k; 46 | for (k = g.first[u]; k != -1; k = g.next[k]) { 47 | Edge e = g.edges[k]; 48 | int v = e.to; 49 | if (d[v] > d[u] + e.weight) { 50 | d[v] = d[u] + e.weight; 51 | q.push(v); 52 | } 53 | } 54 | } 55 | 56 | return d; 57 | } 58 | 59 | int main() { 60 | init(); 61 | int i; 62 | int j; 63 | for (i = 0; i < n; ++i) { 64 | int[] d = spfa(i); 65 | for (j = 0; j < n; ++j) { 66 | if (d[j] == INF) { 67 | print("-1"); 68 | } else { 69 | print(toString(d[j])); 70 | } 71 | print(" "); 72 | } 73 | println(""); 74 | } 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /codegen2/sorting/bubble_sort.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input sorting.in 5 | //#output sorting.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | void bubble_sort(int[] a) { 11 | int i; 12 | int j; 13 | int n = a.size(); 14 | for (i = 0; i < n - 1; ++i) { 15 | for (j = 0; j < n - i - 1; ++j) { 16 | if (a[j] < a[j + 1]) 17 | continue; 18 | int t = a[j]; 19 | a[j] = a[j + 1]; 20 | a[j + 1] = t; 21 | } 22 | } 23 | } 24 | 25 | //#include main.mt SORT:bubble_sort -------------------------------------------------------------------------------- /codegen2/sorting/main.mt: -------------------------------------------------------------------------------- 1 | int main() { 2 | int n = getInt(); 3 | int[] a = new int[n]; 4 | 5 | int i; 6 | for (i = 0; i < n; ++i) 7 | a[i] = getInt(); 8 | 9 | SORT(a); 10 | 11 | for (i = 0; i < n; ++i) 12 | print(toString(a[i]) + " "); 13 | println(""); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /codegen2/sorting/merge_sort.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input sorting.in 5 | //#output sorting.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | //#include ../std/slice.mh TYPE:int 11 | 12 | int[] merge(Slice_int l, Slice_int r) { 13 | if (l.size() == 0) 14 | return r.cloneArray(); 15 | if (r.size() == 0) 16 | return l.cloneArray(); 17 | 18 | int[] res = new int[l.size() + r.size()]; 19 | Slice_int tail = makeSlice_int(res).tail(); 20 | if (l.get(0) < r.get(0)) { 21 | res[0] = l.get(0); 22 | tail.copy(makeSlice_int(merge(l.tail(), r))); 23 | } else { 24 | res[0] = r.get(0); 25 | tail.copy(makeSlice_int(merge(l, r.tail()))); 26 | } 27 | return res; 28 | } 29 | 30 | 31 | void mergeSort(Slice_int a) { 32 | if (a.size() == 1) 33 | return; 34 | int n = a.size(); 35 | int m = n / 2; 36 | mergeSort(a.slice(0, m)); 37 | mergeSort(a.slice(m, n)); 38 | a.copy(makeSlice_int(merge(a.slice(0, m), a.slice(m, n)))); 39 | } 40 | 41 | 42 | void mergeSortInf(int[] a) { 43 | mergeSort(makeSlice_int(a)); 44 | } 45 | 46 | 47 | //#include main.mt SORT:mergeSortInf -------------------------------------------------------------------------------- /codegen2/sorting/quick_sort.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input sorting.in 5 | //#output sorting.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | int partition(int[] a, int p, int r) { 11 | int pivot = a[r]; 12 | int i = p - 1; 13 | int j; 14 | for (j = p; j < r; ++j) { 15 | if (a[j] <= pivot) { 16 | ++i; 17 | int t = a[i]; 18 | a[i] = a[j]; 19 | a[j] = t; 20 | } 21 | } 22 | int t = a[i + 1]; 23 | a[i + 1] = a[r]; 24 | a[r] = t; 25 | return i + 1; 26 | } 27 | 28 | void quick_sort(int[] a, int p, int r) { 29 | if (p >= r) 30 | return; 31 | int q = partition(a, p, r); 32 | quick_sort(a, p, q - 1); 33 | quick_sort(a, q + 1, r); 34 | } 35 | 36 | void quick_sort_inf(int[] a) { 37 | quick_sort(a, 0, a.size() - 1); 38 | } 39 | 40 | //#include main.mt SORT:quick_sort_inf -------------------------------------------------------------------------------- /codegen2/sorting/selection_sort.mx: -------------------------------------------------------------------------------- 1 | /* 2 | //#dump Test Package: Codegen 3 | //#dump Author: Yunwei Ren 4 | //#input sorting.in 5 | //#output sorting.ans 6 | //#dump ExitCode: 0 7 | //#dump InstLimit: -1 8 | */ 9 | 10 | void selection_sort(int[] a) { 11 | int i; 12 | int n = a.size(); 13 | for (i = 0; i < n - 1; ++i) { 14 | int min_pos = i; 15 | int j; 16 | for (j = i + 1; j < n; ++j) { 17 | if (a[j] < a[min_pos]) 18 | min_pos = j; 19 | } 20 | int t = a[i]; 21 | a[i] = a[min_pos]; 22 | a[min_pos] = t; 23 | } 24 | } 25 | 26 | //#include main.mt SORT:selection_sort -------------------------------------------------------------------------------- /codegen2/sorting/sorting.ans: -------------------------------------------------------------------------------- 1 | 2 3 3 4 4 4 7 8 9 9 9 10 10 10 10 10 11 11 11 12 14 15 15 15 18 18 19 19 19 20 20 21 21 22 24 25 25 26 26 27 27 28 29 29 30 31 31 34 36 37 41 41 44 44 45 47 47 47 48 48 49 50 50 51 53 53 55 55 56 56 58 62 64 65 66 67 69 69 69 69 70 71 71 73 73 74 77 78 79 85 87 87 87 92 93 95 95 96 96 96 2 | -------------------------------------------------------------------------------- /codegen2/sorting/sorting.in: -------------------------------------------------------------------------------- 1 | 100 2 | 58 18 71 22 37 93 47 50 3 9 53 95 45 14 74 48 44 20 12 73 29 10 19 28 87 20 27 85 56 87 18 11 55 15 19 10 69 69 29 70 96 69 53 10 30 87 73 26 21 95 19 24 3 25 10 9 67 25 79 41 10 9 48 96 11 44 69 62 47 31 64 21 50 31 11 34 15 51 4 65 71 55 92 49 8 26 27 36 96 4 77 47 4 2 66 41 15 78 7 56 3 | -------------------------------------------------------------------------------- /codegen2/std/array.mh: -------------------------------------------------------------------------------- 1 | class Array_TYPE { 2 | Array_TYPE() { 3 | sz = 0; 4 | storage = new TYPE[16]; 5 | } 6 | 7 | void push_back(TYPE v) { 8 | if (size() == storage.size()) { 9 | doubleStorage(); 10 | } 11 | storage[sz] = v; 12 | ++sz; 13 | } 14 | 15 | TYPE pop_back() { 16 | --sz; 17 | return storage[sz]; 18 | } 19 | 20 | TYPE back() { 21 | return storage[sz - 1]; 22 | } 23 | 24 | TYPE front() { 25 | return storage[0]; 26 | } 27 | 28 | int size() { 29 | return sz; 30 | } 31 | 32 | void resize(int newSize) { 33 | while (storage.size() < newSize) 34 | doubleStorage(); 35 | sz = newSize; 36 | } 37 | 38 | TYPE get(int i) { 39 | return storage[i]; 40 | } 41 | 42 | void set(int i, TYPE v) { 43 | storage[i] = v; 44 | } 45 | 46 | void swap(int i, int j) { 47 | TYPE t = storage[i]; 48 | storage[i] = storage[j]; 49 | storage[j] = t; 50 | } 51 | 52 | 53 | //private: 54 | void doubleStorage() { 55 | TYPE[] copy = storage; 56 | int szCopy = sz; 57 | 58 | storage = new TYPE[copy.size() * 2]; 59 | sz = 0; 60 | 61 | for (; sz != szCopy; ++sz) { 62 | storage[sz] = copy[sz]; 63 | } 64 | } 65 | 66 | 67 | TYPE[] storage; 68 | int sz; 69 | }; 70 | -------------------------------------------------------------------------------- /codegen2/std/heap.mh: -------------------------------------------------------------------------------- 1 | //#include array.mh 2 | 3 | 4 | class Heap_TYPE { 5 | Heap_TYPE() { 6 | storage = new Array_TYPE(); 7 | } 8 | 9 | void push(TYPE v) { 10 | storage.push_back(v); 11 | int x = size() - 1; 12 | while (x > 0) { 13 | int p = pnt(x); 14 | if (storage.get(p).key_() >= storage.get(x).key_()) 15 | break; 16 | storage.swap(p, x); 17 | x = p; 18 | } 19 | } 20 | 21 | TYPE pop() { 22 | TYPE res = storage.front(); 23 | storage.swap(0, size() - 1); 24 | storage.pop_back(); 25 | maxHeapify(0); 26 | return res; 27 | } 28 | 29 | TYPE top() { 30 | return storage.front(); 31 | } 32 | 33 | int size() { 34 | return storage.size(); 35 | } 36 | 37 | // private: 38 | int lchild(int x) { 39 | return x * 2 + 1; 40 | } 41 | 42 | int rchild(int x) { 43 | return x * 2 + 2; 44 | } 45 | 46 | int pnt(int x) { 47 | return (x - 1) / 2; 48 | } 49 | 50 | void maxHeapify(int x) { 51 | int l = lchild(x); 52 | int r = rchild(x); 53 | int largest = x; 54 | 55 | if (l < size() && storage.get(l).key_() > storage.get(largest).key_()) 56 | largest = l; 57 | if (r < size() && storage.get(r).key_() > storage.get(largest).key_()) 58 | largest = r; 59 | 60 | if (largest == x) 61 | return; 62 | 63 | storage.swap(x, largest); 64 | maxHeapify(largest); 65 | } 66 | 67 | Array_TYPE storage; 68 | }; 69 | 70 | -------------------------------------------------------------------------------- /codegen2/std/heap.mt: -------------------------------------------------------------------------------- 1 | //#include heap.mh TYPE:Kv 2 | 3 | class Kv { 4 | int key_() { 5 | return k; 6 | } 7 | 8 | int k; 9 | int v; 10 | }; 11 | 12 | int main() { 13 | Heap_Kv heap = new Heap_Kv(); 14 | 15 | int i; 16 | int top = 0; 17 | int prime = 7; 18 | for (i = 0; i < 100; ++i) { 19 | int k = (prime * i) % 100; 20 | Kv kv = new Kv(); 21 | kv.k = -k; 22 | kv.v = k; 23 | if (-k > top) 24 | top = -k; 25 | heap.push(kv); 26 | if (heap.top().k != top) { 27 | println("Failed"); 28 | return 1; 29 | } 30 | if (heap.size() != i + 1) { 31 | println("Failed: size()"); 32 | return 1; 33 | } 34 | } 35 | 36 | for (i = 0; i < 100; ++i) { 37 | Kv kv = heap.pop(); 38 | if (kv.v != i) { 39 | println("Failed!"); 40 | return 1; 41 | } 42 | if (heap.size() != 99 - i) { 43 | println("Failed: size()"); 44 | return 1; 45 | } 46 | } 47 | 48 | println("Passed!"); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /codegen2/std/queue.mh: -------------------------------------------------------------------------------- 1 | class Queue_TYPE { 2 | Queue_TYPE() { 3 | beg = 0; 4 | end = 0; 5 | storage = new TYPE[16]; 6 | } 7 | 8 | void push(TYPE v) { 9 | if (size() == storage.size() - 1) { 10 | doubleStorage(); 11 | } 12 | storage[end] = v; 13 | end = (end + 1) % storage.size(); 14 | } 15 | 16 | TYPE top() { 17 | return storage[beg]; 18 | } 19 | 20 | TYPE pop() { 21 | if (size() == 0) { 22 | println("Warning: Queue_TYPE::pop: empty queue"); 23 | } 24 | TYPE res = top(); 25 | beg = (beg + 1) % storage.size(); 26 | return res; 27 | } 28 | 29 | int size() { 30 | return (end + storage.size() - beg) % storage.size(); 31 | } 32 | 33 | void doubleStorage() { 34 | TYPE[] copy = storage; 35 | int begCopy = beg; 36 | int endCopy = end; 37 | 38 | storage = new TYPE[copy.size() * 2]; 39 | beg = 0; 40 | end = 0; 41 | 42 | int i = begCopy; 43 | while (i != endCopy) { 44 | storage[end] = copy[i]; 45 | end++; 46 | i = (i + 1) % copy.size(); 47 | } 48 | } 49 | 50 | 51 | TYPE[] storage; 52 | int beg; 53 | int end; 54 | }; -------------------------------------------------------------------------------- /codegen2/std/queue.mt: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Codegen 3 | Author: Yunwei Ren 4 | Input: 5 | === input === 6 | === end === 7 | Output: 8 | === output === 9 | Passed tests. 10 | 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | */ 15 | 16 | //#include queue.mh TYPE:int 17 | 18 | 19 | int main() { 20 | Queue_int q = new Queue_int(); 21 | 22 | int i; 23 | int N = 100; 24 | for (i = 0; i < N; ++i) 25 | q.push(i); 26 | if (q.size() != N) { 27 | println("q.size() != N after pushes"); 28 | return 1; 29 | } 30 | 31 | for (i = 0; i < N; ++i) { 32 | int head = q.top(); 33 | if (head != i) { 34 | println("Head != i"); 35 | return 1; 36 | } 37 | 38 | if (q.pop() != i) { 39 | println("Failed: q.pop() != i"); 40 | return 1; 41 | } 42 | if (q.size() != N - i - 1) { 43 | println("q.size() != N - i - 1"); 44 | return 1; 45 | } 46 | } 47 | 48 | // TODO: stronger tests 49 | 50 | println("Passed tests."); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /codegen2/std/slice.mh: -------------------------------------------------------------------------------- 1 | class Slice_TYPE { 2 | void init(TYPE[] arr) { 3 | storage = arr; 4 | beg = 0; 5 | end = arr.size(); 6 | } 7 | 8 | int size() { 9 | return end - beg; 10 | } 11 | 12 | TYPE get(int n) { 13 | return storage[beg + n]; 14 | } 15 | 16 | void set(int n, TYPE val) { 17 | storage[beg + n] = val; 18 | } 19 | 20 | Slice_TYPE slice(int l, int r) { 21 | Slice_TYPE res = new Slice_TYPE(); 22 | res.storage = storage; 23 | res.beg = beg + l; 24 | res.end = beg + r; 25 | if (res.beg > storage.size() || res.end > storage.size()) 26 | println("Warning: Slice_TYPE::slice: out of range"); 27 | return res; 28 | } 29 | 30 | Slice_TYPE tail() { 31 | return slice(1, size()); 32 | } 33 | 34 | void copy(Slice_TYPE arr) { 35 | if (size() < arr.size()) { 36 | println("Warning: Slice_TYPE::copy: size() < arr.size()"); 37 | } 38 | int i; 39 | for (i = 0; i < arr.size(); ++i) 40 | storage[beg + i] = arr.get(i); 41 | } 42 | 43 | TYPE[] cloneArray() { 44 | TYPE[] res = new TYPE[size()]; 45 | int i; 46 | for (i = 0; i < size(); ++i) { 47 | res[i] = storage[beg + i]; 48 | } 49 | return res; 50 | } 51 | 52 | TYPE[] storage; 53 | int beg; 54 | int end; 55 | }; 56 | 57 | 58 | Slice_TYPE makeSlice_TYPE(TYPE[] arr) { 59 | Slice_TYPE res = new Slice_TYPE(); 60 | res.init(arr); 61 | return res; 62 | } -------------------------------------------------------------------------------- /optim/humble.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Optim 3 | Author: Rongyu You, 14 4 | Input: 5 | === input === 6 | 100 100000 7 | 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 8 | 9 | === end === 10 | Output: 11 | === output === 12 | 284456 13 | 14 | === end === 15 | ExitCode: 0 16 | InstLimit: -1 17 | */ 18 | 19 | // USACO 3.1.3 humble 20 | int MAXK = 105; 21 | int MAXN = 100005; 22 | 23 | int main(){ 24 | int point = 0; 25 | int k; 26 | int MIN; 27 | int K; 28 | int N; 29 | int i; 30 | int[] primes = new int[MAXK]; 31 | int[] pindex = new int[MAXK]; 32 | int[] ans = new int[MAXN]; 33 | K = getInt(); 34 | N = getInt(); 35 | for (i = 0; i < K; ++i) { 36 | primes[i] = getInt(); 37 | } 38 | ans[0] = 1; 39 | while(point <= N){ 40 | MIN = 2139062143; 41 | for (i = 0 ; i < K; ++i){ 42 | while(ans[point] >= primes[i] * ans[pindex[i]]) pindex[i]++; 43 | if (primes[i] * ans[pindex[i]] < MIN){ 44 | MIN = primes[i] * ans[pindex[i]]; 45 | k = i; 46 | } 47 | } 48 | ans[++point] = MIN; 49 | } 50 | print(toString(ans[N])); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /optim/pi.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Optim 3 | Input: 4 | === input === 5 | 6 | === end === 7 | Output: 8 | === output === 9 | 3141592653589793238462643383279528841971693993751058209749445923078164062862089986280348253421170679821480865132823664709384469555822317253594081284811174502841270193852115559644622948954930381964428810975665933446128475648233786783165271201991456485669234634861045432664821339360726024914127372458706606315588174881520920962829254917153643678925903611330530548820466521384146951941511609433057273657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566438602139494639522473719070217986943702770539217176293176752384674818467669451320005681271452635608277857713427577896091736371787214684409012249534301465495853710579227968925892354201995611212902196864344181598136297747713099605187072113499999983729780499510597317328160963185 10 | 11 | === end === 12 | ExitCode: 0 13 | InstLimit: -1 14 | */ 15 | 16 | int main() { 17 | int a = 10000; 18 | int b = 0; 19 | int c = 2800; 20 | int d = 0; 21 | int e = 0; 22 | int[] f = new int[2801]; 23 | int g = 0; 24 | 25 | for (;b-c!=0;) 26 | f[b++] = a/5; 27 | for (;; e = d%a){ 28 | d = 0; 29 | g = c*2; 30 | if (g==0) break; 31 | 32 | for (b=c;;d=d*b){ 33 | d=d+f[b]*a; 34 | f[b] = d%--g; 35 | d=d/g--; 36 | if (--b==0) break; 37 | } 38 | 39 | c = c-14; 40 | print(toString(e+d/a)); 41 | } 42 | 43 | print("\n"); 44 | return 0; 45 | } 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /optim2/binary_tree.ans: -------------------------------------------------------------------------------- 1 | 0: 4 2 | 1: 4 3 | 2: 6 4 | 3: 4 5 | 4: 4 6 | 6: 2 7 | 7: 3 8 | 8: 2 9 | 10: 1 10 | 11: 4 11 | 13: 2 12 | 14: 6 13 | 15: 2 14 | 18: 4 15 | 19: 3 16 | 20: 1 17 | 21: 5 18 | 22: 1 19 | 24: 3 20 | 25: 3 21 | 26: 2 22 | 27: 2 23 | 30: 5 24 | 33: 16 25 | 35: 2 26 | 36: 1 27 | 39: 4 28 | 40: 1 29 | 41: 8 30 | 42: 7 31 | 43: 2 32 | 44: 2 33 | 46: 5 34 | 47: 1 35 | 48: 2 36 | 51: 2 37 | 55: 5 38 | 57: 2 39 | 60: 1 40 | 63: 2 41 | 64: 1 42 | 65: 2 43 | 66: 2 44 | 67: 2 45 | 68: 1 46 | 69: 1 47 | 75: 1 48 | 76: 2 49 | 77: 2 50 | 78: 1 51 | 80: 4 52 | 81: 5 53 | 82: 2 54 | 83: 1 55 | 84: 2 56 | 86: 4 57 | 87: 2 58 | 89: 5 59 | 90: 6 60 | 91: 4 61 | 92: 6 62 | 93: 1 63 | 94: 1 64 | 97: 5 65 | 99: 1 66 | 102: 1 67 | 105: 1 68 | 106: 2 69 | 107: 5 70 | 108: 2 71 | 109: 5 72 | 111: 3 73 | 112: 7 74 | 115: 2 75 | 116: 5 76 | 117: 2 77 | 118: 1 78 | 119: 1 79 | 120: 3 80 | 121: 3 81 | 122: 8 82 | 126: 2 83 | 127: 1 84 | -------------------------------------------------------------------------------- /optim2/binary_tree.in: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /optim2/humble.ans: -------------------------------------------------------------------------------- 1 | 284456 2 | -------------------------------------------------------------------------------- /optim2/humble.in: -------------------------------------------------------------------------------- 1 | 100 100000 2 | 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 3 | -------------------------------------------------------------------------------- /optim2/humble.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Optim 3 | Author: Rongyu You, 14 4 | //#input humble.in 5 | //#output humble.ans 6 | ExitCode: 0 7 | InstLimit: -1 8 | */ 9 | 10 | // USACO 3.1.3 humble 11 | int MAXK = 105; 12 | int MAXN = 100005; 13 | 14 | int main(){ 15 | int point = 0; 16 | int k; 17 | int MIN; 18 | int K; 19 | int N; 20 | int i; 21 | int[] primes = new int[MAXK]; 22 | int[] pindex = new int[MAXK]; 23 | int[] ans = new int[MAXN]; 24 | K = getInt(); 25 | N = getInt(); 26 | for (i = 0; i < K; ++i) { 27 | primes[i] = getInt(); 28 | } 29 | ans[0] = 1; 30 | while(point <= N){ 31 | MIN = 2139062143; 32 | for (i = 0 ; i < K; ++i){ 33 | while(ans[point] >= primes[i] * ans[pindex[i]]) pindex[i]++; 34 | if (primes[i] * ans[pindex[i]] < MIN){ 35 | MIN = primes[i] * ans[pindex[i]]; 36 | k = i; 37 | } 38 | } 39 | ans[++point] = MIN; 40 | } 41 | print(toString(ans[N])); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /optim2/kruskal.ans: -------------------------------------------------------------------------------- 1 | 79894 2 | -------------------------------------------------------------------------------- /optim2/lunatic.ans: -------------------------------------------------------------------------------- 1 | 2 2 | 4 3 | 846 4 | -------------------------------------------------------------------------------- /optim2/lunatic.in: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /optim2/maxflow.ans: -------------------------------------------------------------------------------- 1 | 49 2 | -------------------------------------------------------------------------------- /optim2/maxflow.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterzheng98/Compiler-2020-testcases/be7c85a9acde89423f3f6bb53ff6a6ae56e1fb79/optim2/maxflow.in -------------------------------------------------------------------------------- /optim2/pi.ans: -------------------------------------------------------------------------------- 1 | 3141592653589793238462643383279528841971693993751058209749445923078164062862089986280348253421170679821480865132823664709384469555822317253594081284811174502841270193852115559644622948954930381964428810975665933446128475648233786783165271201991456485669234634861045432664821339360726024914127372458706606315588174881520920962829254917153643678925903611330530548820466521384146951941511609433057273657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566438602139494639522473719070217986943702770539217176293176752384674818467669451320005681271452635608277857713427577896091736371787214684409012249534301465495853710579227968925892354201995611212902196864344181598136297747713099605187072113499999983729780499510597317328160963185 2 | -------------------------------------------------------------------------------- /optim2/pi.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterzheng98/Compiler-2020-testcases/be7c85a9acde89423f3f6bb53ff6a6ae56e1fb79/optim2/pi.in -------------------------------------------------------------------------------- /optim2/pi.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Optim 3 | //#input pi.in 4 | //#output pi.ans 5 | ExitCode: 0 6 | InstLimit: -1 7 | */ 8 | 9 | int main() { 10 | int a = 10000; 11 | int b = 0; 12 | int c = 2800; 13 | int d = 0; 14 | int e = 0; 15 | int[] f = new int[2801]; 16 | int g = 0; 17 | 18 | for (;b-c!=0;) 19 | f[b++] = a/5; 20 | for (;; e = d%a){ 21 | d = 0; 22 | g = c*2; 23 | if (g==0) break; 24 | 25 | for (b=c;;d=d*b){ 26 | d=d+f[b]*a; 27 | f[b] = d%--g; 28 | d=d/g--; 29 | if (--b==0) break; 30 | } 31 | 32 | c = c-14; 33 | print(toString(e+d/a)); 34 | } 35 | 36 | print("\n"); 37 | return 0; 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /optim2/segtree.ans: -------------------------------------------------------------------------------- 1 | 25964 2 | -------------------------------------------------------------------------------- /optim2/segtree.in: -------------------------------------------------------------------------------- 1 | 40000 1000 9977 2 | -------------------------------------------------------------------------------- /optim2/sha_1.ans: -------------------------------------------------------------------------------- 1 | 5B38674EB4BD02CEC1D41C8DE3CC14A9872A2656 2 | ACM 3 | -------------------------------------------------------------------------------- /optim2/sha_1.in: -------------------------------------------------------------------------------- 1 | 1 acm2015 2 | 2 ABC64A57029F21F165A96BDB59F0351C7C7D1769 3 | 0 4 | -------------------------------------------------------------------------------- /script/gen.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # testcases = [ 4 | # "sorting/bubble_sort.mx", 5 | # "sorting/merge_sort.mx", 6 | # "sorting/quick_sort.mx", 7 | # "sorting/selection_sort.mx", 8 | 9 | # "shortest_path/dijkstra.mx", 10 | # "shortest_path/floyd.mx", 11 | # "shortest_path/spfa.mx", 12 | 13 | # "std/queue.mt", 14 | # ] 15 | 16 | testcases = [ 17 | "binary_tree.mx", 18 | "dijkstra.mx", 19 | "humble.mx", 20 | "kruskal.mx", 21 | "lca.mx", 22 | "lunatic.mx", 23 | "maxflow.mx", 24 | "pi.mx", 25 | "segtree.mx", 26 | "sha_1.mx" 27 | ] 28 | 29 | 30 | for testcase in testcases: 31 | cmd = "python3 ./preprocess.py " + \ 32 | "../optim2/" + testcase + " > " + \ 33 | "../optim/" + testcase 34 | os.system(cmd) 35 | -------------------------------------------------------------------------------- /sema/array-package/array-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 15' Haoran Ye 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | int main(){ 11 | int[][] a = new int[5][5]; 12 | int[][] b = new int[5][5]; 13 | int[][] c = new int[5][5]; 14 | a[1][1]=1; 15 | a[1][2]=1; 16 | a[1][3]=1; 17 | a[1][4]=1; 18 | a[2][1]=0; 19 | a[2][2]=1; 20 | a[2][3]=3; 21 | a[2][4]=6; 22 | a[3][1]=0; 23 | a[3][2]=0; 24 | a[3][3]=1; 25 | a[3][4]=7; 26 | a[4][1]=0; 27 | a[4][2]=0; 28 | a[4][3]=0; 29 | a[4][4]=1; 30 | b[1][1]=1; 31 | b[1][2]=1; 32 | b[1][3]=1; 33 | b[1][4]=1; 34 | b[2][1]=0; 35 | b[2][2]=-1; 36 | b[2][3]=3; 37 | b[2][4]=-6; 38 | b[3][1]=0; 39 | b[3][2]=0; 40 | b[3][3]=2; 41 | b[3][4]=11; 42 | b[4][1]=0; 43 | b[4][2]=0; 44 | b[4][3]=0; 45 | b[4][4]=-6; 46 | int i; 47 | int j; 48 | int k; 49 | for(i = 1; i <= 4; i++) 50 | for(j = 1; j <= 4; j++){ 51 | c[i][j] = 0; 52 | for(k = 1; k <= 4; k++){ 53 | c[i][j] = c[i][j] + a[i][k] * b[k][j]; 54 | } 55 | } 56 | return c[1][1] + c[2][2] + c[3][3] + c[4][4]; 57 | } -------------------------------------------------------------------------------- /sema/array-package/array-10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 17' Yifan Xu 5 | Time: 2020-02-26 6 | Verdict: Failed 7 | Comment: The size of array cannot be of boolean type. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | int[] a = new int[false]; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /sema/array-package/array-11.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 17' Yifan Xu 5 | Time: 2020-02-26 6 | Verdict: Failed 7 | Comment: The shape of multidimensional array must be specified from left to right. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | int[][][] a = new int[1][][1]; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /sema/array-package/array-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 15' Sihao Ying 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() { 10 | int i; 11 | int j; 12 | int k; 13 | int[][] A = new int[3][4]; 14 | int[][] B = new int[4][2]; 15 | int[][] C = new int[3][2]; 16 | for (i = 0; i < 3; ++i) 17 | for (j = 0; j < 4; ++j) 18 | A[i][j] = i + j; 19 | for (i = 0; i < 4; ++i) 20 | for (j = 0; j < 2; ++j) 21 | B[i][j] = i * j; 22 | for (i = 0; i < 3; ++i) 23 | for (j = 0; j < 2; ++j) 24 | C[i][j] = 0; 25 | for (i = 0; i < 3; ++i) 26 | for (j = 0; j < 2; ++j) 27 | for (k = 0; k < 4; ++k) 28 | C[i][j] = C[i][j] + A[i][k] * B[k][j]; 29 | int ans = 0; 30 | for (i = 0; i < 3; ++i) 31 | for (j = 0; j < 2; ++j) 32 | ans = ans + C[i][j]; 33 | print(toString(ans)); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /sema/array-package/array-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: A is a 1-dim array not 2-dim 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int i; 12 | int j; 13 | int k; 14 | int[] A = new int[3]; 15 | int[][] B = new int[4][2]; 16 | int[][] C = new int[3][2]; 17 | for (i = 0; i < 3; ++i) 18 | for (j = 0; j < 4; ++j) 19 | A[i][j] = i + j; 20 | for (i = 0; i < 4; ++i) 21 | for (j = 0; j < 2; ++j) 22 | B[i][j] = i * j; 23 | for (i = 0; i < 3; ++i) 24 | for (j = 0; j < 2; ++j) 25 | C[i][j] = 0; 26 | for (i = 0; i < 3; ++i) 27 | for (j = 0; j < 2; ++j) 28 | for (k = 0; k < 4; ++k) 29 | C[i][j] = C[i][j] + A[i][k] * B[k][j]; 30 | int ans = 0; 31 | for (i = 0; i < 3; ++i) 32 | for (j = 0; j < 2; ++j) 33 | ans = ans + C[i][j]; 34 | print(toString(ans)); 35 | return 0; 36 | } -------------------------------------------------------------------------------- /sema/array-package/array-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: a is a 1-dim array, which cannot be initialized by 3-dim new. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int[] a = new int[1][][1]; 12 | return 0; 13 | } -------------------------------------------------------------------------------- /sema/array-package/array-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: Admin 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int[] a = new int[4]; 10 | int main() 11 | { 12 | int[] b = new int[4]; 13 | a=b; 14 | } -------------------------------------------------------------------------------- /sema/array-package/array-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 16' Zhanghao Wu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Assignment with different dimension. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | int[][][] a = new int[3][2][1]; 13 | int[][] b = new int[2][1]; 14 | a = b; 15 | } -------------------------------------------------------------------------------- /sema/array-package/array-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 16' Boyu Tian 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | //test your array type; 12 | int[][][][] a = new int[100][200][300][500]; 13 | int b; 14 | int[][][] c = a[3]; 15 | int[][] d = c[7]; 16 | int e = c[7][8][9]; 17 | if(d[2][1] == c[1][2][3] && d[2][2] == a[1][2][3][4] && d[2][3] == b) 18 | ++c[1][2][3]; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /sema/array-package/array-8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 16' Boyu Tian 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Assignment with different dimension. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | int[][][][] a = new int[1][2][3][4]; 13 | int[] b = new int[5]; 14 | int c = b[a]; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /sema/array-package/array-9.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Array 4 | Author: 16' Jinxiao Chen 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | int [][][]a = (new int[3][2][][])[1]; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sema/basic-package/basic-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 15' Zhuolin Yang 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int main( ) { 10 | int a; 11 | int b; 12 | a = 0; b = 0; 13 | return a + b; 14 | } 15 | -------------------------------------------------------------------------------- /sema/basic-package/basic-10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 15' Sishan Long 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int[][] graph = new int[3][3]; 10 | 11 | int main() { 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-11.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 15' Siqi Liu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | void haha(){ 10 | int a; 11 | return; 12 | } 13 | 14 | int main() { 15 | print("hehe\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /sema/basic-package/basic-12.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Void function cannot return a non-void object 8 | Origin Package: Semantic Extended 9 | */ 10 | void haha(){ 11 | int a; 12 | return 1; 13 | } 14 | 15 | int main() { 16 | print("hehe\n"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /sema/basic-package/basic-13.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Cheng wan 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: main function must return int value 8 | Origin Package: Semantic Extended 9 | */ 10 | void main() {} 11 | 12 | -------------------------------------------------------------------------------- /sema/basic-package/basic-14.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chaoliao 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: No definition of A 8 | Origin Package: Semantic Extended 9 | */ 10 | int main() { 11 | A x = new A; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /sema/basic-package/basic-15.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chao Liao 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: null cannot be assigned 8 | Origin Package: Semantic Extended 9 | */ 10 | int main() { 11 | null = 2016; 12 | } 13 | -------------------------------------------------------------------------------- /sema/basic-package/basic-16.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Redefinition of variable f 8 | Origin Package: Semantic Extended 9 | */ 10 | class A { 11 | int f; 12 | bool f; 13 | }; 14 | 15 | int main() { 16 | return 0; 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-17.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 09' Xiao Jia 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | println("Hello, world!"); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-18.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Admin 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main(){ 10 | int[] a = new int[3]; 11 | print("I have done " + toString(a.size()) + " little things"); 12 | println("too young!"); 13 | print(getString() + toString("\"hahaha\"".length())); 14 | println("four scores and seven years".substring(0, getInt())); 15 | println(toString("45 best songs in the world".parseInt())); 16 | return "45 best songs".ord(5); 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-19.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Admin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Return type not correct(string"hello" to int) 8 | Origin Package: Semantic Pretest 9 | */ 10 | int foo(int a) { 11 | if (a == 1) return 0; 12 | else if (a > 5) { 13 | if (a < 10) { 14 | if (a > 8) { 15 | if (a <= 9) { 16 | return "hello"; 17 | } 18 | } 19 | } 20 | }else { 21 | return 1; 22 | } 23 | } 24 | 25 | int main() { 26 | foo(9); 27 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 15' Bohui Fang 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | void AA() {} 10 | class B {}; 11 | int main() { 12 | int A; 13 | B C = new B; 14 | AA(); 15 | A = 10; 16 | int bbc; 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-20.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Admin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Duplicated name for c 8 | Origin Package: Semantic Pretest 9 | */ 10 | int b; 11 | int c; 12 | int main() { 13 | } 14 | int c; 15 | -------------------------------------------------------------------------------- /sema/basic-package/basic-21.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 10' Youer Pu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Operator + cannot be applied to A objects. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A { 11 | int a; 12 | }; 13 | 14 | int main() { 15 | A a = new A; 16 | A b = new A; 17 | A c = new A; 18 | c = a + b; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-22.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 11' Hang Wu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable Type error. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int a = 1; 12 | int x = a[1]; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /sema/basic-package/basic-23.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 11' Hang Wu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable cannot be declared as 'void' type. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | void a; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-24.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chao Liao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Operator '>>' cannot applied to string object 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | string str = "120"; 12 | int x = str >> 3; 13 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-25.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chao Liao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: true cannot be assigned. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | true = false; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-26.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 10' Tianxing He 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Non-void function should have return value. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class AI { 11 | int a; 12 | }; 13 | 14 | int f(int a, int b) 15 | { 16 | } 17 | 18 | int main() { 19 | int b; 20 | AI sa = new AI; 21 | f(b, sa); 22 | } 23 | -------------------------------------------------------------------------------- /sema/basic-package/basic-27.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chao Liao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Duplicated class identifier. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A { 11 | int x; 12 | }; 13 | 14 | class A { 15 | int x; 16 | int y; 17 | }; 18 | 19 | int main() { 20 | } 21 | 22 | -------------------------------------------------------------------------------- /sema/basic-package/basic-28.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Pikachu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A { 10 | int x; 11 | int y; 12 | }; 13 | 14 | int main() { 15 | } 16 | 17 | -------------------------------------------------------------------------------- /sema/basic-package/basic-29.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 10' Youer Pu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: int cannot assign to A object. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A { 11 | int x; 12 | int y; 13 | int z; 14 | }; 15 | 16 | int main() { 17 | int t; 18 | A x; 19 | t = x; 20 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | //This is the most basic test. 11 | //基本测试,注释是中文应该要能搞吧 12 | 13 | int main() 14 | { 15 | int[][] array = new int[3][3]; 16 | array[0] = null; 17 | println(toString(array[0].size())); 18 | array[0] = new int[10]; 19 | int i; 20 | for(i = 0; i < 10; ++i) 21 | array[0][i] = i * i; // 22 | println(toString(array[0][9])); 23 | while(true) 24 | { 25 | break; 26 | continue; 27 | } 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /sema/basic-package/basic-30.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Pikachu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Function cannot be lvalue. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A { 11 | int x; 12 | int y; 13 | int z; 14 | }; 15 | 16 | int f(){ 17 | return 1; 18 | } 19 | 20 | int main() { 21 | int t; 22 | A x; 23 | f() = x; 24 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-31.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 10' Youer Pu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Constant object cannot be assigned. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | "a" = "b"; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-32.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 12' Chao Liao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Binary operator && can only apply to bool object. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | if ("20" && "16") { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sema/basic-package/basic-33.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 09' Xiao Jia 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: unknown identifier x. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int f(int anything) { 11 | return 0; 12 | } 13 | 14 | int main() { 15 | int x = f(x); 16 | return x; 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-34.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Tianyi Liu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Duplicated name for x. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int x, x; 12 | } 13 | -------------------------------------------------------------------------------- /sema/basic-package/basic-35.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Zhihan Jin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Duplicated name for main. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class main{ 11 | 12 | }; 13 | int main() { 14 | int a = (new int[])[1]; 15 | } 16 | -------------------------------------------------------------------------------- /sema/basic-package/basic-36.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuxi Liu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Array declaration is not correct. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int a; 12 | bool b; 13 | string c; 14 | bool flag = true; 15 | { 16 | if (b == b) { 17 | flag = false; 18 | } 19 | int b; 20 | bool c; 21 | string a; 22 | { 23 | int c; 24 | if (a + a - a == a) { 25 | flag = true; 26 | } 27 | bool a; 28 | string b; {int [][][][][][][][][][][][][][][][][][][][] a = new int [1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][][l][][][]; 29 | { 30 | return 0; 31 | } 32 | } 33 | } 34 | } 35 | return 0; 36 | return 0; 37 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-37.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yutong Xie 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: null cannot be assigned to primitive type variable 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | 12 | int[][] graph = new int[3][]; 13 | graph[0] = null; 14 | graph[1] = new int[10]; 15 | graph[2] = new int[30]; 16 | graph[2][0] = null; // null cannot be assigned to primitive type variable 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /sema/basic-package/basic-38.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jinxiao Chen 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: int cannot be the name of identifier. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class int 11 | { 12 | int a; 13 | }; 14 | int main() 15 | { 16 | ;;;;;;;; 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-39.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jinxiao Chen 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Non-void function should return non-null value. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | 13 | if(true) 14 | //return "heiheihei"; 15 | int i = 0; 16 | i = 1; 17 | return null; 18 | } 19 | //TimerChen 20 | //Failure Compile -------------------------------------------------------------------------------- /sema/basic-package/basic-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: No main() function 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int f() 12 | { 13 | println("No main function."); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /sema/basic-package/basic-40.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yikai Li 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable cannot be void. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main(){ 11 | void[] a; 12 | } 13 | -------------------------------------------------------------------------------- /sema/basic-package/basic-41.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yikai Li 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class Array{ 10 | int size(){ 11 | return 0; 12 | } 13 | }; 14 | 15 | int main(){ 16 | Array a = null; 17 | a.size(); 18 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-42.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Xuehui Sun 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Duplicate name for function name and class name. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class x 11 | { 12 | int x; 13 | x() 14 | { 15 | x=1; 16 | } 17 | }; 18 | x x(x a) 19 | { 20 | return a; 21 | } 22 | int x; 23 | int main() 24 | { 25 | x a; 26 | x(a); 27 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-43.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Siyuan Feng 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: main function should not have parameters. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main(int X) 11 | { 12 | return 0; 13 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-44.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Siyuan Feng 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() { 10 | int[] a = (new int[2][])[0]; 11 | return a[0]; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-45.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yaoyao Ding 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: New expression cannot apply to void. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | new void; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-46.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Zhanghao Wu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable cannot be void. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() { 11 | int a; 12 | int b; 13 | a = a + b; 14 | foo(); 15 | return 0; 16 | } 17 | 18 | void foo(){ 19 | void s = foo(); return s; 20 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-47.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Xiaoyuan Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | // function in function 10 | // null as para 11 | int too(int young) { 12 | return young; 13 | } 14 | int young(int too) { 15 | return too; 16 | } 17 | int simple(sometimes naive) { 18 | return 1926; 19 | } 20 | class sometimes { 21 | int naive; 22 | void make_money() { 23 | this.naive++; 24 | } 25 | }; 26 | int main() { 27 | sometimes naive = null; 28 | print(toString( 29 | too(young(too(simple(naive)))) 30 | )); 31 | } 32 | -------------------------------------------------------------------------------- /sema/basic-package/basic-48.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Xiaoyuan Liu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: No main function. 8 | Origin Package: Semantic Pretest 9 | */ 10 | // no main 11 | int main; 12 | class Main { 13 | int main() { 14 | return 0; 15 | } 16 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-49.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Xiaoyuan Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | //dot hell 10 | class A { int a;}; 11 | class B { A b; }; 12 | class C { B c; }; 13 | class D { C d; }; 14 | class E { D e; }; 15 | class F { E f; }; 16 | class G { F g; }; 17 | G world = new G; 18 | void hello(int world) { 19 | } 20 | int main() { 21 | hello(world.g.f.e.d.c.b.a); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Variable cannot be void 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | void a; 13 | void b; 14 | a = b; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-50.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Pikachu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: no target named A. 8 | Origin Package: Semantic Pretest 9 | */ 10 | //dot hell 11 | class A { int a;}; 12 | class B { A b; }; 13 | class C { B c; }; 14 | class D { C d; }; 15 | class E { D e; }; 16 | class F { E f; }; 17 | class G { F g; }; 18 | G world = new G; 19 | void hello(int world) { 20 | } 21 | int main() { 22 | hello(world.g.f.e.d.c.b.a.A); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-51.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuxuan Duan 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Return type error. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | return this; 13 | } 14 | -------------------------------------------------------------------------------- /sema/basic-package/basic-52.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuxuan Duan 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Return type error. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A 11 | { 12 | bool b; 13 | int e; 14 | 15 | void c(int b) 16 | { 17 | this.b = b; 18 | } 19 | }; 20 | int main() 21 | { 22 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-53.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Zhou Fan 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | string a = "\n\n\n\"\\\""; 10 | 11 | class A { 12 | bool b; 13 | }; 14 | 15 | int main() { 16 | println(a + " " + a); 17 | // what a mess 18 | int [] [] [] a; 19 | a = new int [2] [] []; 20 | if (true) { 21 | int[] b = a [1] [1]; 22 | int [][] c = a [1]; 23 | A[][] a = new A[2][]; 24 | if (a[1][1].b) {} 25 | } 26 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-54.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuwei Wu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Class B is not defined. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A{ 11 | }; 12 | int main(){ 13 | A a = new B(); 14 | } 15 | -------------------------------------------------------------------------------- /sema/basic-package/basic-55.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuxuan Duan 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A 10 | { 11 | void b(int d) 12 | { 13 | } 14 | int e; 15 | 16 | void c(int b) 17 | { 18 | this.b(b); 19 | } 20 | }; 21 | int main() 22 | { 23 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-56.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Zihao Xu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int a = 0; 10 | 11 | class A{ 12 | int f(){ 13 | b = a; 14 | return b; 15 | } 16 | int b; 17 | }; 18 | 19 | 20 | int main(){ 21 | int[ ][ ] graph = new int[3][]; //be careful about the space! 22 | graph[0] = null; 23 | graph[1] = new int[10]; 24 | graph[2] = new int[30]; 25 | 26 | int i = 0; 27 | for ((i == 1)&& true;;){ 28 | break; 29 | } 30 | return 0; 31 | } 32 | 33 | //This is a comment without "\n" at the end of the sentence, may cause a little problem if you don't handle it well. -------------------------------------------------------------------------------- /sema/basic-package/basic-57.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yunxuan Xiao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Invalid expression and lack of ';' 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | int [] idiot = new int [3] 12 | "I think I forget some thing...; 13 | print("but it seems to be all right") 14 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-58.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jiangbei Li 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: a is not a class. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A{ 11 | int a; 12 | }; 13 | A a; 14 | int main() { 15 | A b = new a(); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-59.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Muyang Li 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | int [] a = null; 12 | int [][] b = null; 13 | if (null == null) 14 | a = null; 15 | else b = null; 16 | } 17 | -------------------------------------------------------------------------------- /sema/basic-package/basic-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: int cannot be converted to string object 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() 12 | { 13 | int a; 14 | { 15 | string a; 16 | a = 1; 17 | a = "wow"; 18 | } 19 | a = "f"; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /sema/basic-package/basic-60.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Hongyu Yan 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int yhy(int yhy){ 10 | return yhy; 11 | } 12 | 13 | int main() { 14 | A c; 15 | return yhy(c.b.a.b.a.v[10]); 16 | } 17 | class A { 18 | int [] v; 19 | B b; 20 | }; 21 | class B { 22 | A a; 23 | }; 24 | -------------------------------------------------------------------------------- /sema/basic-package/basic-61.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jie Xie 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: This cannot be assigned. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A{A a;void f(A t){this=t;}} 11 | int main(){ 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /sema/basic-package/basic-62.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jie Xie 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A{int a;}; 10 | A foo(){ 11 | return new A(); 12 | } 13 | int main(){ 14 | foo().a=1; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-63.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Jie Xie 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main(){ 10 | int a=0; 11 | (a)=1; 12 | } 13 | -------------------------------------------------------------------------------- /sema/basic-package/basic-64.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yuxi Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() { 10 | if (vvvvvv()) { } 11 | else { 12 | int i = vvwvvv(); 13 | for ( ; !vvvvvv() && vvvvvv() || vvvvvv(); i < vvwvvv()) { 14 | println("hahaha"); 15 | } 16 | vvvvwv(); 17 | } 18 | return (vwvvvv() + toString(vvwvvv())).parseInt(); 19 | } 20 | 21 | bool vvvvvv() { 22 | if (vwvvvv() >= vwvvvv() && vwvvvv() <= vwvvvv()) { 23 | return toString(vvwvvv()) == vwvvvv(); 24 | } 25 | return vwvvvv() != vwvvvv(); 26 | } 27 | 28 | void vvvvwv() { 29 | int tmp = vvwvvv(); 30 | if ((vvwvvv() ^ vwvvvv().parseInt()) > -(++tmp) || (vvvvvv() == (vwvvvv() + vwvvvv() >= vwvvvv()))) { 31 | for ( ; ; ) { 32 | break; 33 | } 34 | } 35 | return; 36 | } 37 | 38 | string vwvvvv() { 39 | return getString(); 40 | } 41 | 42 | int vvwvvv() { 43 | return vwvvvv().parseInt() % vwvvvv().parseInt(); 44 | } 45 | -------------------------------------------------------------------------------- /sema/basic-package/basic-65.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Chang Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | string s = "\\"; 12 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-66.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yunfeng Lin 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A 10 | { 11 | int b; 12 | B foo; 13 | A f() 14 | { 15 | return foo.g().foo; 16 | } 17 | }; 18 | 19 | int main() 20 | { 21 | B foo; 22 | foo = (foo.foo.foo).foo.foo.foo.foo.g(); 23 | foo.foo.f().foo.g().foo.foo.g(); 24 | foo.foo.foo.foo.foo.foo.foo.g().foo.b = getString().length(); 25 | return 0; 26 | } 27 | 28 | class B 29 | { 30 | int a; 31 | A foo; 32 | B g() 33 | { 34 | //test left value for increment result 35 | (++(++a))++; 36 | return foo.f().foo; 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /sema/basic-package/basic-67.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yunfeng Lin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: left value operation is invalid here. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | int a; 13 | ++(((++(((++(++a))++)++))++)++); 14 | ++a++; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /sema/basic-package/basic-68.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Yunfeng Lin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Illegal member access. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A{ 11 | int a; 12 | A ptr; 13 | B alt; 14 | B af(){ 15 | return alt.pf(); 16 | } 17 | A pf(){ 18 | return alt.af(); 19 | } 20 | }; 21 | 22 | int main() 23 | { 24 | A ptr; 25 | B alt; 26 | //legal 27 | ptr.ptr.(ptr).alt.alt.a = alt.af().pf().af().pf().b; 28 | alt.pf(); 29 | //illegal 30 | ptr.(alt.ptr); 31 | ptr.alt.(b+1); 32 | 33 | return 1; 34 | } 35 | 36 | class B{ 37 | int b; 38 | A alt; 39 | B ptr; 40 | A af(){ 41 | return alt.pf(); 42 | } 43 | B pf(){ 44 | return alt.af(); 45 | } 46 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-69.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Muyang Li 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | (new int[5])[0] = 1; 12 | return 0; 13 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: a.f(c) has void return value, which conflicts int. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A 12 | { 13 | int a; 14 | void f(int b) 15 | { 16 | a = b; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | int c = 10; 23 | A a = new A; 24 | return a.f(c); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /sema/basic-package/basic-70.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 16' Lizhen Zhu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: The assignment of 2-D array should follow the order from the first dimension. 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main(){} 11 | int [] [] graph = new int [][4]; -------------------------------------------------------------------------------- /sema/basic-package/basic-71.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: Pikachu 5 | Time: 2020-02-02 6 | Verdict: Success 7 | Origin Package: Semantic 8 | */ 9 | int main() { 10 | int a; 11 | bool b; 12 | string c; 13 | bool flag = true; 14 | { 15 | if (b == b) { 16 | flag = false; 17 | } 18 | int b; 19 | bool c; 20 | int a; 21 | { 22 | int c; 23 | if (a + a - a == a) { 24 | flag = true; 25 | } 26 | bool a; 27 | string b; {int [][][][][][][][][][][][][][][][][][][][] a = new int [1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][][][][][]; 28 | { 29 | return 0; 30 | } 31 | } 32 | } 33 | } 34 | return 0; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /sema/basic-package/basic-8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: No definition of A 8 | Origin Package: Semantic Pretest 9 | */ 10 | A f(A x) 11 | { 12 | return A.this; 13 | } 14 | int main() 15 | { 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /sema/basic-package/basic-9.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Basic 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Variable is not available for back reference.(a is not defined, Chap 13.1) 8 | Origin Package: Semantic Pretest 9 | */ 10 | int main() 11 | { 12 | a = 0; 13 | return a; 14 | } 15 | int a; -------------------------------------------------------------------------------- /sema/breakcontinue-package/breakcontinue-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Break and Continue 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: break outside the loop 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | while (1 > 0) { } 13 | break; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /sema/breakcontinue-package/breakcontinue-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Break and Continue 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: continue outside the loop 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | while (1 > 0) { } 13 | continue; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /sema/breakcontinue-package/breakcontinue-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Break and Continue 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | int main() { 11 | while (1 > 0) { 12 | break; 13 | continue; 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /sema/breakcontinue-package/breakcontinue-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Break and Continue 4 | Author: Pikachu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: continue outside the loop is invalid. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | continue; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /sema/breakcontinue-package/breakcontinue-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Break and Continue 4 | Author: 16' Lizhen Zhu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: break outside the loop is invalid. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | int i; 13 | for (i = 0; i < 10; ++i) 14 | break; 15 | break; 16 | } -------------------------------------------------------------------------------- /sema/builtin-func-package/builtin-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Built-In 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | int main(){ 11 | int[] a = new int[3]; 12 | print("I have done " + toString(a.size()) + " little things"); 13 | println("too young!"); 14 | print(getString() + toString("\"hahaha\"".length())); 15 | println("four scores and seven years".substring(0, getInt())); 16 | println(toString("45 best songs in the world".parseInt())); 17 | return "45 best songs".ord(5); 18 | } -------------------------------------------------------------------------------- /sema/builtin-func-package/builtin-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Built-In 4 | Author: 16' Yaoyao Ding 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | int f() { 11 | int[] a = ((new int[2][3][3])[0])[1]; 12 | { 13 | string b = (new string[3])[0]; 14 | { 15 | int c = ((new string[3][3][3])[0][1])[2].length(); 16 | return c; 17 | } 18 | } 19 | } 20 | int main() { 21 | string a = "abc"; 22 | print(a); 23 | println(toString(a.length())); 24 | print(getString()); 25 | print(toString(3)); 26 | string c = a.substring(0,10); 27 | int b = a.parseInt(); 28 | { 29 | int b = a.ord(3); 30 | { 31 | string b; 32 | } 33 | return b; 34 | } 35 | return getInt(); 36 | } 37 | -------------------------------------------------------------------------------- /sema/builtin-func-package/builtin-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Built-In 4 | Author: 16' Muyang Li 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: size is not defined for class array. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class array{ 12 | }; 13 | 14 | int main(){ 15 | array a; 16 | a.size(); 17 | } -------------------------------------------------------------------------------- /sema/builtin-func-package/builtin-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Built-In 4 | Author: 16' Muyang Li 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: size is not defined for class Array. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class Array{ 12 | }; 13 | 14 | int main(){ 15 | Array a = null; 16 | a.size(); 17 | } 18 | -------------------------------------------------------------------------------- /sema/class-package/class-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | A object; 11 | 12 | int main() { 13 | object.func1(2, 3); 14 | 15 | object.set(0, 1) 16 | .set(1, 0); 17 | 18 | object.copy(object.getThis()) 19 | .copy(object.getThis().getThis()); 20 | 21 | return 0; 22 | } 23 | 24 | class A { 25 | void func1(int x, int y) { 26 | func2(this.x*x, this.y*y); 27 | } 28 | 29 | void func2(int xx, int yy) { 30 | func1(x*this.x, y*this.y); 31 | } 32 | 33 | A set(int xx, int yy) { 34 | return set(x, y).set(this.x, this.y).set(xx, yy).getThis(); 35 | } 36 | 37 | A copy(A other) { 38 | // this = other; 39 | return this; 40 | } 41 | 42 | A getThis() { 43 | return getThis().getThis().getThis().getThis().copy(this); 44 | } 45 | 46 | int x; int y; 47 | }; -------------------------------------------------------------------------------- /sema/class-package/class-10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 12' Chao Liao 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Class Foo has no member named naive 8 | Origin Package: Semantic Extended 9 | */ 10 | class Foo { 11 | int young; 12 | }; 13 | 14 | int main() { 15 | Foo chairman = new Foo; 16 | chairman.naive = -2147483648; 17 | } -------------------------------------------------------------------------------- /sema/class-package/class-11.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: Admin 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | A b = null; 10 | int c = b.a; 11 | 12 | int main() { 13 | } 14 | 15 | class A{ 16 | int a; 17 | void fun() { 18 | a = c; 19 | } 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /sema/class-package/class-12.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Xinhao Chen 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Mismatched constructor name. 8 | Origin Package: Semantic Extended 9 | */ 10 | class A { 11 | B() {} 12 | }; 13 | 14 | class B { 15 | A() {} 16 | }; 17 | 18 | int main() { 19 | A b = new A; 20 | B a = new B; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /sema/class-package/class-13.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 16' Zhihan Jin 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class A { 10 | B t; 11 | A() { 12 | t = new B(); 13 | } 14 | }; 15 | 16 | class B { 17 | A t; 18 | B() { 19 | t = new A(); 20 | } 21 | }; 22 | 23 | int main() { 24 | A a = new A; 25 | B b = new B; 26 | a.t = b; 27 | b.t = a; 28 | } -------------------------------------------------------------------------------- /sema/class-package/class-14.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 16' Zihao Xu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Constructor Type Error. 8 | Origin Package: Semantic Extended 9 | */ 10 | int a; 11 | 12 | class b{ 13 | int b() { 14 | this.a = a; 15 | } 16 | int a; 17 | }; 18 | 19 | int main(){ 20 | return 0; 21 | } -------------------------------------------------------------------------------- /sema/class-package/class-15.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: Pikachu 5 | Time: 2020-02-03 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | A get() { return new A; } // this is valid 10 | 11 | class A { 12 | A() { 13 | 14 | } 15 | }; 16 | 17 | int main() { return 0; } -------------------------------------------------------------------------------- /sema/class-package/class-16.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 17' Yifan Xu 5 | Time: 2020-02-26 6 | Verdict: Failed 7 | Comment: The name of class constructor must be the same as the class name. 8 | Origin Package: Semantic Pretest 9 | */ 10 | class A {}; 11 | class B { 12 | A() {} 13 | }; 14 | 15 | int main() 16 | { 17 | return 0; 18 | } -------------------------------------------------------------------------------- /sema/class-package/class-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Jinning Li 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | class naive 11 | { 12 | interesting[][] HongKong; 13 | naive() 14 | { 15 | HongKong = new interesting[100][]; 16 | HongKong[1] = null; 17 | int i = 0; 18 | for(i = 1; i < 99; i ++) 19 | { 20 | HongKong[i] = new interesting[233]; 21 | } 22 | HongKong[99] = new interesting[1]; 23 | return; 24 | } 25 | 26 | int Journalist(interesting news) 27 | { 28 | println(news.learnmore); 29 | println("news.learnmore"); 30 | return 1; 31 | } 32 | 33 | }; 34 | 35 | class interesting 36 | { 37 | string learnmore; 38 | int second; 39 | 40 | interesting() 41 | { 42 | second = 0; 43 | learnmore = "+1s"; 44 | second = learnmore.length() + second; 45 | } 46 | }; 47 | 48 | int main() 49 | { 50 | naive[] Shanghai = new naive[233]; 51 | interesting[][] Beijing = new interesting[12][34]; 52 | // ++Beijing[1][1].second = ((Beijing[0][0].second))*(((((((((((((((((((((23333))))))))))))))))))))); 53 | // ++++++++--------++++++------++++++++Beijing[2][2].second ; 54 | {} 55 | { 56 | {} 57 | { 58 | 59 | } 60 | } 61 | return 0; 62 | } -------------------------------------------------------------------------------- /sema/class-package/class-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Bowen Tan 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class AAA { 10 | string str; 11 | 12 | AAA() { 13 | str = "abcde"; 14 | } 15 | 16 | void AAAprint() { 17 | print(str); 18 | print(toString(str.length())); 19 | } 20 | }; 21 | 22 | class BBB { 23 | AAA a; 24 | 25 | BBB() { 26 | a.str = a.str + "1234567890"; 27 | } 28 | }; 29 | 30 | int main() { 31 | int a; 32 | int b = a + a * a % a; 33 | 34 | BBB[][] bb = new BBB[10][10]; 35 | 36 | int i; 37 | for (i = 1; i <= 10; i++) { 38 | bool i = false; 39 | if (i) { 40 | print("a"); 41 | } else { 42 | println("b"); 43 | } 44 | } 45 | 46 | bb[5][5].a.AAAprint(); 47 | } -------------------------------------------------------------------------------- /sema/class-package/class-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Yueyang Xianzang 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: The variable A and class A is dumplicated. 8 | Origin Package: Semantic Extended 9 | */ 10 | class A 11 | { 12 | A func() 13 | { 14 | A a=this; 15 | a=null; 16 | return this; 17 | } 18 | int a; 19 | } 20 | int main() 21 | { 22 | A A; 23 | A.func(); 24 | A.func(); 25 | return 0; 26 | } -------------------------------------------------------------------------------- /sema/class-package/class-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 14' Huichen Li 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Modified Flag: True 8 | Origin ID: 610 9 | Origin Package: Semantic Extended 10 | */ 11 | class Cat{ 12 | void greet(){ 13 | println("MIAOMIAOMIAO"); 14 | } 15 | }; 16 | 17 | class Lamb{ 18 | void greet(){ 19 | println("MIEMIEMIE"); 20 | } 21 | }; 22 | 23 | class Animals{ 24 | Cat c; 25 | Lamb l; 26 | Animals(){ 27 | c = new Cat; 28 | l = new Lamb; 29 | } 30 | void greet(){ 31 | c.greet(); 32 | l.greet(); 33 | } 34 | }; 35 | 36 | int main(){ 37 | Cat cat; 38 | cat = new Cat; 39 | Lamb lamb; 40 | lamb = new Lamb; 41 | Animals a = new Animals; 42 | a.c = cat; 43 | a.l = lamb; 44 | a.greet(); 45 | } -------------------------------------------------------------------------------- /sema/class-package/class-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A 10 | { 11 | C c; 12 | }; 13 | class B 14 | { 15 | C c; 16 | }; 17 | class C 18 | { 19 | int a; 20 | string b; 21 | }; 22 | int main() 23 | { 24 | A a = new A; 25 | B b = new B; 26 | C c = new C; 27 | a.c = c; 28 | b.c = c; 29 | c.a = 0; 30 | c.b = getString(); 31 | if(a.c.b + b.c.b == c.b + c.b) 32 | { 33 | c.b = c.b + c.b; 34 | } 35 | c.b = toString("123.456".parseInt()); 36 | if(c.b == toString(123)) 37 | { 38 | println(c.b); 39 | } 40 | return 0; 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /sema/class-package/class-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | CLASS a = new CLASS; 12 | a.c = 0; 13 | println(toString(a.c)); 14 | a.a = a; 15 | println(toString(a.a.a.a.a.a.a.a.a.a.a.c)); 16 | CLASS b = new CLASS; 17 | b.a = a; 18 | b.b = b; 19 | a.b = b; 20 | println(toString(a.b.a.b.a.b.a.c)); 21 | return 0; 22 | } 23 | 24 | class CLASS 25 | { 26 | CLASS a; 27 | CLASS b; 28 | int c; 29 | }; -------------------------------------------------------------------------------- /sema/class-package/class-8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: cannot return any value in a constructor 8 | Origin Package: Semantic Extended 9 | */ 10 | A get() { return new A; } // this is valid 11 | 12 | class A { 13 | A() { 14 | return get(); // cannot return any value in a constructor 15 | } 16 | }; 17 | 18 | int main() { return 0; } -------------------------------------------------------------------------------- /sema/class-package/class-9.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Classes 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | A a; 10 | B b; 11 | 12 | int main() { 13 | a = new A; 14 | b = new B; 15 | A[] a = (new A).many()[0]; 16 | B[][] b = (new B).many()[1][1].many(); 17 | return 0; 18 | } 19 | 20 | class A { 21 | B b; 22 | A one() { 23 | return a; 24 | } 25 | 26 | A[][] many() { 27 | return new A[10][10]; 28 | } 29 | }; 30 | 31 | class B { 32 | A a; 33 | B one() { 34 | return b; 35 | } 36 | 37 | B[][] many() { 38 | return new B[10][10]; 39 | } 40 | }; -------------------------------------------------------------------------------- /sema/codeforces-package/1145A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-02 6 | Verdict: Success 7 | Origin Package: Codeforces 1145A #52445759 8 | */ 9 | int n; 10 | int[] a = new int[20]; 11 | int jud(int x){ 12 | int i,j; 13 | for(i=0;ia[i*x+j+1])flag=true; 17 | } 18 | if(!flag)return 1; 19 | } 20 | return 0; 21 | } 22 | int i; 23 | int main(){ 24 | n = getInt(); 25 | for(i=0;i 0;i = i / 2) 27 | if(jud(i) > 0){ 28 | print(toString(i)); 29 | return 0; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /sema/codeforces-package/122A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-03 6 | Verdict: Success 7 | Origin Package: Codeforces 122A #61467904 8 | */ 9 | 10 | int n; 11 | int main() 12 | { 13 | //int n; 14 | //scanf("%d",&n); 15 | n = getInt(); 16 | if((n%4==0)||(n%7==0)||(n%47==0)||(n%74==0)||(n%477==0)) 17 | print("YES"); 18 | else 19 | print("NO"); 20 | // printf((n%4==0)||(n%7==0)||(n%47==0)||(n%74==0)||(n%477==0) ? "YES" : "NO"); 21 | } -------------------------------------------------------------------------------- /sema/codeforces-package/158A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-03 6 | Verdict: Success 7 | Origin Package: Codeforces 158A #62259103 8 | */ 9 | 10 | int[] a = new int[50]; 11 | int m; 12 | int k; 13 | int i; 14 | int main() 15 | { 16 | m = getInt(); 17 | k = getInt(); 18 | //scanf("%d%d",&m,&k); 19 | for(i=0;i=a[k-1]&&a[i] > 0&&i1)c++; 25 | } 26 | printlnInt(c); 27 | //printf("%d\n",c); 28 | } -------------------------------------------------------------------------------- /sema/codeforces-package/263A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-03 6 | Verdict: Success 7 | Origin Package: Codeforces 263A #48540584 8 | */ 9 | 10 | int n; 11 | int r; 12 | int c; 13 | int i; 14 | int j; 15 | int abs(int c){ 16 | if(c>0) return c; 17 | return -c; 18 | } 19 | 20 | int main() 21 | { 22 | // int n,r,c,i,j; 23 | for (i=0;i<5;i++) 24 | for (j=0;j<5;j++) 25 | { 26 | n = getInt(); 27 | //scanf("%d", &n); 28 | if (n==1) 29 | {r=i;c=j;}} 30 | printInt(abs(2-r) + abs(2-c)); 31 | // printf("%d",abs(2-r)+abs(2-c)); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /sema/codeforces-package/399A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-02 6 | Verdict: Success 7 | Origin Package: Codeforces 399A #44003944 8 | */ 9 | int n; 10 | int p; 11 | int k; 12 | int i; 13 | int main() { 14 | n = getInt(); 15 | p = getInt(); 16 | k = getInt(); 17 | if(p-k>1) print("<< "); 18 | for(i= p-k; i<=p+k;i++) 19 | if(1<= i && i <= n) { 20 | if(i==p){ 21 | print("("); 22 | print(toString(i)); 23 | print(") "); 24 | } 25 | else{ 26 | printInt(i); 27 | print(" "); 28 | } 29 | } 30 | if(p + k < n) print(">> "); 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /sema/codeforces-package/4A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-02 6 | Verdict: Success 7 | Origin Package: Codeforces 4A #57460997 8 | */ 9 | int w; 10 | int main(){ 11 | w = getInt(); 12 | if (w%2==0&&w>2) 13 | print("YES"); 14 | else 15 | print("NO"); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /sema/codeforces-package/69A.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: codeforces 4 | Author: Pikachu 5 | Time: 2020-02-03 6 | Verdict: Success 7 | Origin Package: Codeforces 69A #42823903 8 | */ 9 | 10 | int p; 11 | int q; 12 | int r; 13 | int x = 0; 14 | int y = 0; 15 | int z = 0; 16 | int n; 17 | int i; 18 | int main() 19 | { //int p,q,r,x=0,y=0,z=0,n,i; 20 | n = getInt(); 21 | //scanf("%d", &n); 22 | for(i=0;i 10) 17 | println(s.substring(0, 1) + toString(l-2) + s.substring(l-1, l)); 18 | // printf("%c%d%c\n",s[0],l-2,s[l-1]); 19 | else 20 | // printf("%s\n",s); 21 | println(s); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /sema/condition.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Conditions and scopes 4 | Author: Pikachu 5 | Time: 2019-10-13 6 | */ 7 | class S{ 8 | int a; 9 | S getThis(){ return this; } 10 | }; 11 | 12 | void test(){ 13 | int a = -1; 14 | if(a){ ++a; } // expected error: condition cannot be int objects 15 | while(++a){ ++a; } //expected error: condition cannot be non-bool expression 16 | while(a != 0){ ++a; } // accepted 17 | 18 | S s; 19 | while(s) { ++s.a; } // expected error: condition cannot be compond objects 20 | while(s.a != false) { ++s.a; } // expected error: binary expression '!=' cannot be applied to int and bool 21 | while(s.getThis().getThis().getThis() != s){ ++s.a; } // accepted 22 | while(s.getThis() = a){ ++s.a; } // expected error: condition cannot be assignment sentences 23 | // another expected error: this cannot be modified 24 | while(S st){ ++st.a; } // expected error: Declaration cannot be conditions 25 | while(int a = 0){ ++st.a; } // expected error: Declaration cannot be conditions 26 | 27 | 28 | for(int i = 0; i != s.a; ++i){ --s.a; } // expected error: initial sentence cannot be declarations 29 | for(i = 0; i != s.a; ++i){ --s.a; } // expected error: variable i is not defined before. 30 | for(a = 0; a != s.a; ++a){ --s.a; } // accepted. 31 | for(;;){ --s.a; } // accepted. 32 | for(;a - s.a; --a){ --s.a; } // expected error: condition cannot be int objects 33 | for(;;){ int a = -1; } // accepted. Notes: this a is in the subscope of the test 34 | int a = -2; // expected error: redefinition of variable a 35 | 36 | for(;;) int a = -2; // accepted: a is in the new scope 37 | } 38 | 39 | int main(){ 40 | println("Good Luck!"); 41 | return 0; 42 | } -------------------------------------------------------------------------------- /sema/expression-package/expression-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Expression 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: test suffix increase, lvalue is expected. 8 | Origin Package: Semantic Extended 9 | */ 10 | int main() { 11 | int a; 12 | a++++; 13 | } 14 | -------------------------------------------------------------------------------- /sema/expression-package/expression-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Expression 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int main() { 10 | int a; 11 | ++++a; 12 | } 13 | -------------------------------------------------------------------------------- /sema/expression-package/expression-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Expression 4 | Author: 15' Sidi Lu 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: RValue cannot be function. 8 | Origin Package: Semantic Extended 9 | */ 10 | class testret 11 | { 12 | int name; 13 | testret() 14 | { 15 | name = 2; 16 | } 17 | }; 18 | testret ret_const() 19 | { 20 | testret r = new testret; 21 | return r; 22 | } 23 | int main() 24 | { 25 | ret_const() = new testret; 26 | } 27 | -------------------------------------------------------------------------------- /sema/expression-package/expression-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Expression 4 | Author: 12' Chao Liao 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Operator ++ cannot be applied to str. 8 | Origin Package: Semantic Extended 9 | */ 10 | int main() { 11 | string str = "sjtu"; 12 | str++; 13 | } 14 | -------------------------------------------------------------------------------- /sema/function-package/function-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Function parameters do not match 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int f(int a, int b) { 12 | return a + b; 13 | } 14 | 15 | int main() { 16 | int x; 17 | x = f(1, 2, 3); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /sema/function-package/function-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Non-void function must have a return value 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A { 12 | int x; 13 | int y; 14 | int z; 15 | }; 16 | 17 | B f() { 18 | int a; 19 | a = 1; 20 | } 21 | 22 | int main() { 23 | return 0; 24 | } -------------------------------------------------------------------------------- /sema/function-package/function-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Non-void function must have a return value 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A { 12 | int x; 13 | int y; 14 | int z; 15 | }; 16 | 17 | A f() { 18 | int a; 19 | a = 1; 20 | } 21 | 22 | int main() { 23 | A a; 24 | a(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /sema/function-package/function-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: Admin 5 | Time: 2020-02-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | int[] foo(){ 11 | return new int[10]; 12 | } 13 | 14 | int[] foo_1(int[] args){ 15 | return args; 16 | } 17 | 18 | int main() { 19 | int[] a = foo(); 20 | int[] b = foo_1(a); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /sema/function-package/function-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: Admin 5 | Time: 2020-02-11 6 | Verdict: Fail 7 | Comment: Return type doesn't match in function foo_1. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int[] foo(){ 12 | return new int[10]; 13 | } 14 | 15 | int[][] foo_1(int[] args){ 16 | return args; 17 | } 18 | 19 | int main() { 20 | int[] a = foo(); 21 | int[] b = foo_1(a); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /sema/function-package/function-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Function 4 | Author: Admin 5 | Time: 2020-02-11 6 | Verdict: Fail 7 | Comment: Return type doesn't match in function foo_1. 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A{ 12 | int _; 13 | int __; 14 | int ____; 15 | }; 16 | 17 | int[] foo(){ 18 | return new int[10]; 19 | } 20 | 21 | A[] foo_1(int[] args){ 22 | return args; 23 | } 24 | 25 | int main() { 26 | int[] a = foo(); 27 | int[] b = foo_1(a); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sema/if-package/if-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: If 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: condition cannot be int objects 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() 12 | { 13 | if(1) 14 | { 15 | 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /sema/if-package/if-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: If 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: condition cannot be non-bool objects 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A { int a; }; 12 | 13 | int main() { 14 | A a = new A; 15 | if (a) {} 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /sema/if-package/if-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: If 4 | Author: 10' Youer Pu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: condition cannot be non-bool objects 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | class A { int a; }; 12 | 13 | int main() { 14 | A a = new A; 15 | if (a) {} 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /sema/loop-package/loop-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Loop 4 | Author: 12' Chao Liao 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: Loop condition cannot be non-bool object 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | string institute = "zhiyuan"; 13 | for (; institute; ) { 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /sema/loop-package/loop-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Loop 4 | Author: 09' Xiao Jia 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | 10 | int N; 11 | int h = 99; 12 | int i = 100; 13 | int j = 101; 14 | int k = 102; 15 | int total = 0; 16 | 17 | int main() { 18 | int a; 19 | int b; 20 | int c; 21 | int d; 22 | int e; 23 | int f; 24 | N=getInt(); 25 | for ( a=1; a<=N; a++ ) 26 | for ( b=1; b<=N; b++ ) 27 | for ( c=1; c<=N; c++ ) 28 | for ( d=1; d<=N; d++ ) 29 | for ( e=1; e<=N; e++ ) 30 | for ( f=1; f<=N; f++ ) 31 | if (a!=b && a!=c && a!=d && a!=e && a!=f && a!=h && a!=i && a!=j && a!=k 32 | && b!=c && b!=d && b!=e && b!=f && b!=h && b!=i && b!=j && b!=k 33 | && c!=d && c!=e && c!=f && c!=h && c!=i && c!=j && c!=k 34 | && d!=e && d!=f && d!=h && d!=i && d!=j && d!=k 35 | && e!=f && e!=h && e!=i && e!=j && e!=k 36 | && f!=h && f!=i && f!=j && f!=k && i!=j && h!=k) 37 | { 38 | total++; 39 | } 40 | 41 | println(toString(total)); 42 | return 0; 43 | } -------------------------------------------------------------------------------- /sema/loop-package/loop-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Loop 4 | Author: Admin 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Condition should be bool 8 | Origin Package: Semantic Pretest 9 | */ 10 | 11 | int main() { 12 | int i; 13 | for (;i;); 14 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 15' Jiacheng Yang 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | int reed = 12883127; 11 | int n; 12 | 13 | int rand() { 14 | reed = reed + (reed << 5) + 1727317; 15 | if (reed % 1772371 < 1000) { 16 | reed = reed ^ (reed + 818277) | (reed - 18217); 17 | } 18 | int const = 1 << 30; 19 | return reed & (~const >> 2); 20 | } 21 | 22 | class Test{ 23 | string [][] array; 24 | Test() { 25 | int i; 26 | int j; 27 | this.array = new string [n][]; 28 | for (i = 0; i < n; i++) { 29 | int sum; 30 | sum = 0; 31 | this.array[j] = new string[(i + i * i + 3) | 13]; 32 | int s = 0; 33 | for (j = 0; j < ((i + i * i + 2) | 13); j++) { 34 | this.array[i][j] = toString(rand()); 35 | } 36 | } 37 | } 38 | void printme() { 39 | int i; 40 | int j; 41 | int k; 42 | for (i = 0; i < n; i++) 43 | for (j = 0; j - i * i < i + 3; j++) { 44 | println(this.array[i][j]); 45 | println("toInt: " + toString(this.array[i][j].parseInt())); 46 | int l; 47 | int r; 48 | l = rand() % array[i][j].length(); 49 | r = rand() % array[i][j].length(); 50 | if (l > r) { 51 | int t; 52 | t = l; 53 | l = r; 54 | r = t; 55 | } 56 | println("substr: " + this.array[i][j].substring(l, r)); 57 | for (k = 0; k + 1 < array[i][j].length() + 1; k = k + 2) { 58 | print(toString(array[i][j].ord(k)) + " "); 59 | } 60 | println(""); 61 | } 62 | } 63 | }; 64 | 65 | int main() { 66 | n = getInt(); 67 | println("BY Kipsora"); 68 | Test a = new Test; 69 | a.printme(); 70 | a.array = new string[3][3]; 71 | if (true) { int a; } 72 | else { int a; } 73 | for (;;) { int a; } 74 | while (true) { int a; } 75 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-10.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 15' Sidi Lu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | string s; 12 | int a; 13 | for (a = 1; a < 2 << 2; ++a) 14 | { 15 | //Duplicated name test 16 | string s; 17 | int p = 2; 18 | //Dynamic array test 19 | int[][] dynamic_array = new int[a][a]; 20 | } 21 | //Single varible expression test 22 | // s; 23 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-11.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 15' Bingyu Kong 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class Node 10 | { 11 | int num; 12 | Node() 13 | { 14 | num = 1; 15 | } 16 | Node work(int p) 17 | { 18 | int i = 10; 19 | for (; i <= this.num; i++) 20 | { 21 | return this; 22 | } 23 | return this; 24 | } 25 | }; 26 | Node[] a = new Node[723]; 27 | Node[] b = null; 28 | string str = "19asdojkhkj1"; 29 | int [][] map = new int [153][144]; 30 | void work() 31 | { 32 | int i = 11; 33 | int tmp1 = i; 34 | a[tmp1].work(i); 35 | return ; 36 | } 37 | int main() 38 | { 39 | int i; 40 | int n = 10213; 41 | for (i = 0; i < n; i++) 42 | { 43 | int flag = n * i - 13; 44 | if(flag < a[i].num) 45 | { 46 | 47 | //print("%d", (flag - a[i].num) * 14); 48 | } 49 | else if(false) 50 | { 51 | a[i - 1].work(flag); 52 | break; 53 | } 54 | else 55 | { 56 | if(true) 57 | { 58 | a[i] = a[i + 1].work(flag); 59 | work(); 60 | continue; 61 | } 62 | } 63 | 64 | } 65 | return 0; 66 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-13.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Bo Dai 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int N = 8; 10 | int[] row = new int[8]; 11 | int[] col = new int[8]; 12 | int[][] d = new int[2][]; 13 | 14 | void printBoard() { 15 | int i; 16 | int j; 17 | for (i = 0; i < N; i++) { 18 | for (j = 0; j < N; j++) { 19 | if (col[i] == j) 20 | print(" O"); 21 | else 22 | print(" ."); 23 | } 24 | println(""); 25 | } 26 | println(""); 27 | } 28 | 29 | void search(int c) { 30 | if (c == N) { 31 | printBoard(); 32 | } 33 | else { 34 | int r; 35 | for (r = 0; r < N; r++) { 36 | if (row[r] == 0 && d[0][r+c] == 0 && d[1][r+N-1-c] == 0) { 37 | row[r] = 1; 38 | d[0][r+c] = 1; 39 | d[1][r+N-1-c] = 1; 40 | col[c] = r; 41 | search(c+1); 42 | row[r] = 0; 43 | d[0][r+c] = 0; 44 | d[1][r+N-1-c] = 0; 45 | } 46 | } 47 | } 48 | } 49 | 50 | int main() { 51 | int i; 52 | for (i = 0; i < 2; i ++) 53 | d[i] = new int[8 + 8 - 1]; 54 | search(0); 55 | return 0; 56 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-14.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Huan Yang 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int N; 10 | int head; 11 | int startx; 12 | int starty; 13 | int targetx; 14 | int targety; 15 | int x; 16 | int y; 17 | int[] xlist = new int[12000]; 18 | int[] ylist = new int[12000]; 19 | int tail; 20 | int ok; 21 | int now; 22 | int[] dx = new int[8]; 23 | int[] dy = new int[9]; 24 | int[][] step; 25 | int i; 26 | int j; 27 | 28 | void origin(int N) 29 | { 30 | step = new int[N][]; 31 | for (i = 0; i < N; i = i ++ ) { 32 | step[i] = new int[N]; 33 | for (j = 0; j < N; j = j ++ ) 34 | step[i][j] = 0; 35 | } 36 | } 37 | 38 | bool check(int a) { 39 | return ((a < N) && (a >= 0)); 40 | } 41 | 42 | void addList(int x, int y) { 43 | if (check(x) && check(y) && step[x][y] == -1) { 44 | tail ++; 45 | xlist[tail] = x; 46 | ylist[tail] = y; 47 | step[x][y] = now + 1; 48 | if ((x == targetx) && (y == targety)) ok = 1; 49 | } 50 | } 51 | int main() { 52 | origin(106); 53 | N = getInt(); 54 | targetx = N - 1; 55 | targety = N - 1; 56 | for (i = 0; i < N; i ++) 57 | for (j = 0; j < N; j ++) 58 | step[i][j] = -1; 59 | dx[0] = -2; dy[0] = -1; 60 | dx[1] = -2; dy[1] = 1; 61 | dx[2] = 2; dy[2] = -1; 62 | dx[3] = 2; dy[3] = 1; 63 | dx[4] = -1; dy[4] = -2; 64 | dx[5] = -1; dy[5] = 2; 65 | dx[6] = 1; dy[6] = -2; 66 | dx[7] = 1; dy[7] = 2; 67 | while (head <= tail) { 68 | x = xlist[head]; 69 | y = ylist[head]; 70 | now = step[x][y]; 71 | for (j = 0;j < 8;j ++) 72 | addList(x + dx[j], y + dy[j]); 73 | if (ok == 1) break; 74 | head ++; 75 | } 76 | if (ok == 1) println(toString(step[targetx][targety])); 77 | else print("no solution!\n"); 78 | return 0; 79 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-15.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: Pikachu 5 | Time: 2019-10-20 6 | Verdict: Fail 7 | Comment: d[i] is int, not an array. 8 | Origin Package: Semantic Extended 9 | */ 10 | int N = 8; 11 | int[] row = new int[8]; 12 | int[] col = new int[8]; 13 | int[] d = new int[2]; 14 | 15 | void printBoard() { 16 | int i; 17 | int j; 18 | for (i = 0; i < N; i++) { 19 | for (j = 0; j < N; j++) { 20 | if (col[i] == j) 21 | print(" O"); 22 | else 23 | print(" ."); 24 | } 25 | println(""); 26 | } 27 | println(""); 28 | } 29 | 30 | void search(int c) { 31 | if (c == N) { 32 | printBoard(); 33 | } 34 | else { 35 | int r; 36 | for (r = 0; r < N; r++) { 37 | if (row[r] == 0 && d[0][r+c] == 0 && d[1][r+N-1-c] == 0) { 38 | row[r] = 1; 39 | d[0][r+c] = 1; 40 | d[1][r+N-1-c] = 1; 41 | col[c] = r; 42 | search(c+1); 43 | row[r] = 0; 44 | d[0][r+c] = 0; 45 | d[1][r+N-1-c] = 0; 46 | } 47 | } 48 | } 49 | } 50 | 51 | int main() { 52 | int i; 53 | for (i = 0; i < 2; i ++) 54 | d[i] = new int[8 + 8 - 1]; 55 | search(0); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-17.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Huan Yang 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int N; 10 | int head; 11 | int startx; 12 | int starty; 13 | int targetx; 14 | int targety; 15 | int x; 16 | int y; 17 | int[] xlist = new int[12000]; 18 | int[] ylist = new int[12000]; 19 | int tail; 20 | int ok; 21 | int now; 22 | int[][] step; 23 | int i; 24 | int j; 25 | 26 | void origin(int N) 27 | { 28 | step = new int[N][]; 29 | for (i = 0; i < N; i = i ++ ) { 30 | step[i] = new int[N]; 31 | for (j = 0; j < N; j = j ++ ) 32 | step[i][j] = 0; 33 | } 34 | } 35 | 36 | bool check(int a, int N) { 37 | return ((a < N) && (a >= 0)); 38 | } 39 | 40 | void addList(int x, int y) { 41 | if (check(x, N) && check(y, N) && step[x][y] == -1) { 42 | tail = tail + 1; 43 | xlist[tail] = x; 44 | ylist[tail] = y; 45 | step[x][y] = now + 1; 46 | if ((x == targetx) && (y == targety)) ok = 1; 47 | } 48 | } 49 | 50 | int main() { 51 | origin(106); 52 | N = getInt(); 53 | targetx = N - 1; 54 | targety = N - 1; 55 | for (i = 0; i < N; i ++) 56 | for (j = 0; j < N; j ++) 57 | step[i][j] = -1; 58 | while (head <= tail) { 59 | x = xlist[head]; 60 | y = ylist[head]; 61 | now = step[x][y]; 62 | addList(x-1, y-2); 63 | addList(x-1, y+2); 64 | addList(x+1, y-2); 65 | addList(x+1, y+2); 66 | addList(x-2, y-1); 67 | addList(x-2, y+1); 68 | addList(x+2, y-1); 69 | addList(x+2, y+1); 70 | if (ok == 1) break; 71 | head = head + 1; 72 | } 73 | if (ok == 1) println(toString(step[targetx][targety])); 74 | else print("no solution!\n"); 75 | return 0; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /sema/misc-package/misc-18.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Bo Dai 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int n; 10 | int[] a; 11 | 12 | void exchange(int x,int y) 13 | { 14 | int t=a[x]; 15 | a[x]=a[y]; 16 | a[y]=t; 17 | } 18 | 19 | int makeHeap() { 20 | int i; 21 | int t; 22 | int j; 23 | i = (n - 1) / 2; 24 | t = 0; 25 | j = 0; 26 | while (i >= 0) { 27 | j = i * 2; 28 | if (i*2+1 a[j]) { 30 | exchange(i,j); 31 | } 32 | i = i - 1; 33 | } 34 | return 0; 35 | } 36 | 37 | int adjustHeap(int n) { 38 | int i; 39 | int j; 40 | int t; 41 | i = 0; 42 | j = 0; 43 | t = 0; 44 | while (i * 2 < n) { 45 | j = i*2; 46 | if (i*2+1 a[j]) { 48 | int t = a[i]; 49 | a[i] = a[j]; 50 | a[j] = t; 51 | i = j; 52 | } 53 | else break; 54 | } 55 | return 0; 56 | } 57 | 58 | int heapSort() { 59 | int t; 60 | int k; 61 | t = 0; 62 | for (k = 0; k < n; k = k + 1) { 63 | t = a[0]; 64 | a[0] = a[n-k-1]; 65 | a[n-k-1] = t; 66 | adjustHeap(n-k-1); 67 | } 68 | return 0; 69 | } 70 | 71 | int main() { 72 | int i; 73 | n = getString().parseInt(); 74 | a = new int[n]; 75 | 76 | for (i = 0; i < a.size(); i = i + 1) 77 | a[i] = i; 78 | makeHeap(); 79 | heapSort(); 80 | for (i = 0; i < a.size(); i = i + 1) 81 | print(toString(a[i]) + " "); 82 | print("\n"); 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /sema/misc-package/misc-20.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 09' Xiao Jia 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int tak(int x, int y, int z) { 10 | if ( y < x ) return 1 + tak( tak(x-1, y, z), tak(y-1, z, x), tak(z-1, x, y) ); 11 | else return z; 12 | } 13 | 14 | int main(){ 15 | int a; 16 | int b; 17 | int c; 18 | a=getInt(); 19 | b=getInt(); 20 | c=getInt(); 21 | println(toString(tak(a,b,c))); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-21.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: Admin 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int Wallace = 1<<10; 10 | class sometimes { 11 | int naive; 12 | string haha; 13 | }; 14 | class ArrayWrapper { 15 | sometimes[][] arr; 16 | }; 17 | int get(int n) { 18 | if (n == 0) return 0; 19 | return 1 + get(n-1); 20 | } 21 | int main() { 22 | sometimes keep = new sometimes; 23 | int n = 3; 24 | keep.naive = 2 + get(n) * 4 / 5; 25 | bool fun = (keep.naive - 5 * 3) != (666 ^ 7); 26 | while (getInt() < Wallace) { 27 | keep.naive++; 28 | ++n; 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-22.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: Admin 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class experience { 10 | int naive; 11 | }; 12 | int main() { 13 | if (true) 14 | if (true) 15 | print("hello"); 16 | else 17 | print("bye"); 18 | 19 | experience[][] exp = new experience[5][6]; 20 | string[] vec; 21 | int[][] mat = new int[5][6]; 22 | vec = new string[10]; 23 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-23.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Tianxing He 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() 10 | { 11 | int[][] a = new int[100][]; 12 | int i; 13 | int j; 14 | for (i = 0; i < 100; i++) 15 | a[i] = new int[100]; 16 | int sum = 0; 17 | 18 | for (i = 0;i < 100;i++) 19 | for (j = 0;j < 100;j++) 20 | a[i][j] = 0; 21 | for (i = 0;i < 100;i++) 22 | if (i > 20 && i < 80) { 23 | for (j = 0;j < 100;j++) 24 | if (j > 5 || i < 90) 25 | a[i][j] = j + (100 - 1 + 1 - 1 + 1) / 2; 26 | } 27 | 28 | for (i = 0;i < 100;i++) 29 | for (j = 0;j < 100;j++) 30 | sum = sum + a[i][j]; 31 | println(toString(sum)); 32 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-26.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Bo Dai 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int cd(int d, string a, string b, string c, int sum) { 10 | if (d == 1) { 11 | println("move " + a + " --> " + c); 12 | sum++; 13 | } else { 14 | sum = cd(d - 1, a, c, b, sum); 15 | println("move " + a + " --> " + c); 16 | sum = cd(d - 1, b, a, c, sum); 17 | sum++; 18 | } 19 | return sum; 20 | } 21 | 22 | int main() { 23 | string a = "A"; 24 | string b = "B"; 25 | string c = "C"; 26 | int d = getInt(); 27 | int sum = cd(d, a, b, c, 0); 28 | println(toString(sum)); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-28.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 10' Bo Dai 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | //int a[10100]; 10 | int[] a = new int[10100]; 11 | int n = 10000; 12 | 13 | int qsrt(int l, int r) { 14 | int i = l; 15 | int j = r; 16 | int x = a[(l + r) / 2]; 17 | while (i <= j) { 18 | while (a[i] < x) i++; 19 | while (a[j] > x) j--; 20 | if (i <= j) { 21 | int temp = a[i]; 22 | a[i] = a[j]; 23 | a[j] = temp; 24 | i++; 25 | j--; 26 | } 27 | } 28 | if (l < j) qsrt(l, j); 29 | if (i < r) qsrt(i, r); 30 | return 0; 31 | } 32 | 33 | int main() { 34 | int i; 35 | for (i = 1; i <= n; i++) 36 | a[i] = n + 1 - i; 37 | qsrt(1, n); 38 | for (i = 1; i <= n; i++) { 39 | // printf("%d ", a[i]); 40 | print(toString(a[i])); 41 | print(" "); 42 | } 43 | print("\n"); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-33.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 16' Keda Sheng 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class A{ 10 | int b; 11 | A() 12 | { 13 | } 14 | }; 15 | int B() 16 | { 17 | int c; 18 | { 19 | int c;;;;{} 20 | int s;(s+1); 21 | } 22 | return c; 23 | 24 | } 25 | int main() 26 | { 27 | int k; 28 | bool[][] u = new bool[3][]; 29 | { 30 | u[1] = new bool[2]; 31 | u[3] = new bool[999]; 32 | u[2] = null; 33 | } 34 | (new int[2][])[3]; 35 | u = null; 36 | string s = toString(getInt()); 37 | for (k = 1; k < (s+"thisisastring//\\\n").substring(1,3).ord(0); k = k+u.size()) 38 | { 39 | println(getString()); 40 | } 41 | //efhudaghdjg 42 | for(;;)while(true){} 43 | int aa = (((((1))))+1);;; 44 | ++aa;aa++; 45 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-35.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 16' Tianzhe Wang 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main() { 10 | A tmp; 11 | return tmp.a.b.s.substring(0,1).length(); 12 | } 13 | class A{ 14 | B a; 15 | }; 16 | class B{ 17 | C b; 18 | }; 19 | class C{ 20 | string s; 21 | }; 22 | 23 | -------------------------------------------------------------------------------- /sema/misc-package/misc-37.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 16' Jiuqin Zhou 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | int main(){ 10 | int i = 0; 11 | 12 | // test forStmt block 13 | for(i = 0; i < 10; ++i){ 14 | string i = ""; 15 | print(i + "\n"); 16 | } 17 | for(i = 0; i < 10; ++i) 18 | int i = 0; 19 | for(i = 0; i < 10; ++i) 20 | for(i = 0; i < 10; ++i) 21 | int i = 0; 22 | { 23 | int i = 0; 24 | } 25 | 26 | // test ifStmt block 27 | if(i == 0){ 28 | string i = ""; 29 | println(i + i); 30 | } 31 | else{ 32 | string i = "-1"; 33 | println(i + i + getString()); 34 | } 35 | if(i == 0) 36 | int i = 0; 37 | else if( i == 0) 38 | if( i == 0) 39 | int i = 0; 40 | else 41 | int i = 0; 42 | { 43 | int i = 0; 44 | } 45 | 46 | // test WhileStmt block 47 | while(toString(i) == "0"){ 48 | string i = "11h"; 49 | int i_ = i.parseInt(); 50 | } 51 | while(i == 0) 52 | int i = 0; 53 | while(i == 0) 54 | while(i == 0) 55 | int i = 0; 56 | { 57 | int i = 0; 58 | } 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /sema/misc-package/misc-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 15' Zhenjia Xu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | class ClassA{ 11 | int num; 12 | string str; 13 | bool[] bool_arr; 14 | ClassA(){ 15 | str = ""; 16 | num = 1; 17 | bool_arr = null; 18 | bool_arr = new bool[100]; 19 | return; 20 | } 21 | ClassA getClassA(int x){ 22 | ClassA tmp = new ClassA; 23 | tmp.num = x; 24 | this.num = x; 25 | return tmp; 26 | } 27 | string getString(){ 28 | return str; 29 | } 30 | }; 31 | int Main(int parameter){ 32 | ClassA a = new ClassA; 33 | ClassA b = a.getClassA(parameter); 34 | b.num = parameter; 35 | parameter = getInt(); 36 | int[] int_arr = (new int[2][])[3]; 37 | int number = b.getString().parseInt() + getString().ord(123) % b.getString().substring(1, 3).length(); 38 | string str1 = "123"; 39 | string str2 = "456"; 40 | int num = 0; 41 | if(str1 < str2) num++; 42 | if(str1 <= str2) num++; 43 | if(str1 > str2) num++; 44 | if(str1 >= str2) num++; 45 | if((str1 + str2) == (str1 + str2)){ 46 | num++; 47 | }else if(false) 48 | num--; 49 | else --num; 50 | for(;;){ 51 | break; 52 | } 53 | while(true) 54 | continue; 55 | println(str1); 56 | print(str2); 57 | return num; 58 | } 59 | int main() { 60 | Main(0); 61 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 15' Yiran Wu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class testClass1 10 | { 11 | int a; 12 | int b; 13 | int c; 14 | int classFunc() 15 | { 16 | return 0; 17 | } 18 | }; 19 | class testClass2 20 | { 21 | testClass1 obj; 22 | }; 23 | int max(int a,int b) 24 | { 25 | if(a>b) return a; 26 | else return b; 27 | } 28 | 29 | int main() 30 | { 31 | int i=max(3,5); 32 | int j=0; 33 | int[][] arr=new int[5][5]; 34 | for(i=0;i<5;i++) 35 | { 36 | j=0; 37 | while(j<100000) 38 | { 39 | arr[i][++j]=(i+j)&((i<<10)+1^(5*j)); 40 | if(j>4 && max(1,2)==2) break; 41 | else continue; 42 | } 43 | } 44 | string str="compiler2017"; 45 | print(str.substring(0,str.length()-1)); 46 | i=1; 47 | return max(-i,0); 48 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 14' Tiancheng Xie 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | string miracle = "\"orange________\""; 10 | 11 | class moment_ring 12 | { 13 | string[] singers; 14 | string lryics; 15 | void init() 16 | { 17 | this.singers = new string[9]; 18 | lryics = "kii te yo ima no kimochi wa\nsouda na souda na katari kirenai\n..."; 19 | } 20 | }; 21 | 22 | int depth; 23 | 24 | void another_fun() 25 | { 26 | moment_ring song; 27 | song.init(); 28 | depth--; 29 | if(depth > 0) 30 | another_fun(); 31 | else 32 | //fun(); 33 | fun(2017); 34 | } 35 | 36 | class test 37 | { 38 | string txt; 39 | test init() 40 | { 41 | txt = "you should pass this one"; 42 | return this; 43 | } 44 | test init2(test t) 45 | { 46 | t.txt = "TAT"; 47 | this.txt = t.txt; 48 | return t; 49 | } 50 | }; 51 | 52 | int main() 53 | { 54 | int a; 55 | { 56 | int a = 0; 57 | println(toString(a)); 58 | } 59 | a = 1; 60 | test nico; 61 | println(nico.init().txt); 62 | println(toString(nico.init().txt.ord(0))); 63 | depth = 3; 64 | another_fun(); 65 | ; 66 | return toString(fun(10).ord(0)).ord(0); 67 | } 68 | 69 | string fun(int pos) 70 | { 71 | if(pos < 0) 72 | return ""; 73 | return fun(pos - 1) + toString(miracle.ord(pos)); 74 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 14' Xingyuan Sun 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class point { 10 | int x; 11 | int y; 12 | int z; 13 | point() { 14 | x = 0; 15 | y = 0; 16 | z = 0; 17 | } 18 | void set(int a_x, int a_y, int a_z){ 19 | x = a_x; 20 | y = a_y; 21 | z = a_z; 22 | } 23 | int sqrLen(){ 24 | return x * x + y * y + z * z; 25 | } 26 | int sqrDis(point other) { 27 | return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y) + (z - other.z) * (z - other.z); 28 | } 29 | int dot(point other) { 30 | return x * other.x + y * other.y + z * other.z; 31 | } 32 | point cross(point other) { 33 | point retval; 34 | retval.set(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x); 35 | return retval; 36 | } 37 | void add(point other) { 38 | x = x + other.x; 39 | y = y + other.y; 40 | z = z + other.z; 41 | } 42 | void sub(point other) { 43 | x = x - other.x; 44 | y = y - other.y; 45 | z = z - other.z; 46 | } 47 | void printPoint() { 48 | println("(" + toString(x) + ", " + toString(y) + ", " + toString(z) + ")"); 49 | } 50 | }; 51 | 52 | int main() { 53 | point a; 54 | point b; 55 | point c; 56 | point d; 57 | a.printPoint(); 58 | a.set(849, -463, 480); 59 | b.set(-208, 585, -150); 60 | c.set(360, -670, -742); 61 | d.set(-29, -591, -960); 62 | a.add(b); 63 | b.add(c); 64 | d.add(c); 65 | c.sub(a); 66 | b.sub(d); 67 | d.sub(c); 68 | c.add(b); 69 | a.add(b); 70 | b.add(b); 71 | c.add(c); 72 | a.sub(d); 73 | a.add(b); 74 | b.sub(c); 75 | println(toString(a.sqrLen())); 76 | println(toString(b.sqrLen())); 77 | println(toString(b.sqrDis(c))); 78 | println(toString(d.sqrDis(a))); 79 | println(toString(c.dot(a))); 80 | b.cross(d).printPoint(); 81 | a.printPoint(); 82 | b.printPoint(); 83 | c.printPoint(); 84 | d.printPoint(); 85 | } -------------------------------------------------------------------------------- /sema/misc-package/misc-9.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Misc 4 | Author: 14' Xiaojun Wu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Pretest 8 | */ 9 | class Fibonacci{ 10 | int x; 11 | int result; 12 | 13 | void reset(){ 14 | x = 0; 15 | result = 0; 16 | } 17 | 18 | void set_problem(int x_in){ 19 | reset(); 20 | x = x_in; 21 | } 22 | 23 | int calc(int cur_num){ 24 | if (cur_num == 0) 25 | return 1; 26 | else 27 | return cur_num * calc(cur_num-1); 28 | } 29 | 30 | int get_result(){ 31 | result = calc(x); 32 | return result; 33 | } 34 | }; 35 | 36 | int main(){ 37 | Fibonacci teacher; 38 | teacher = new Fibonacci; 39 | int x; 40 | for (x = 0; x < 5; x++){ 41 | teacher.set_problem(x); 42 | println(toString(teacher.get_result())); 43 | } 44 | return 0; 45 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 15' Peiyao Sheng 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int x = 1; 10 | bool b(bool x){ 11 | return x; 12 | } 13 | class C{ 14 | C(){ 15 | x(); 16 | {int x;} 17 | } 18 | void x(){} 19 | }; 20 | int main(){ 21 | string x = "789dcbadcba\n"; 22 | int y; 23 | C c; 24 | c.x(); 25 | b(true); 26 | {y = x.parseInt(); 27 | int x = y;} 28 | return y; 29 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class A {}; 10 | class B { B() {{{{{ return; }}}}} }; // single return is allowed in constructor 11 | class C { int func() { return 93; } }; 12 | int main() {} 13 | void func() { 14 | if(false);else; 15 | while(true); 16 | for(;;); 17 | return; 18 | {;{{;{{}{}}}};{{};{}}}; 19 | new A[10][][][]; 20 | (new C).func() + (new C).func(); // new is a kind of expression 21 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 14' Yurong You 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable a, b outside valid scope. 8 | Origin Package: Semantic Extended 9 | */ 10 | int f(){ 11 | for (;;) int a = 1; 12 | return a; 13 | } 14 | 15 | int g(){ 16 | while(true) int b = 1; 17 | return b; 18 | } 19 | int main(){ 20 | return 0; 21 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 14' Yurong You 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Variable c, d outside valid scope. 8 | Origin Package: Semantic Extended 9 | */ 10 | int h(){ 11 | if (true) int c = 1; 12 | return c; 13 | } 14 | 15 | int k(){ 16 | if (true) ; 17 | else int d = 1; 18 | return d; 19 | } 20 | 21 | int l(){ 22 | if (true) ; 23 | else if (true) int e = 1; 24 | return e; 25 | } 26 | 27 | int main(){ 28 | return 0; 29 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 16' Jinxiao Chen 5 | Time: 2019-11-11 6 | Verdict: Fail 7 | Comment: Type for variable i has changed to string. 8 | Origin Package: Semantic Extended 9 | */ 10 | string i; 11 | int main() 12 | { 13 | if(true) 14 | { 15 | string i; 16 | i = "Are u stupid?"; 17 | } 18 | if(false) 19 | { 20 | int i; 21 | i = "I do not know."; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 16' Xiaoyuan Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | // class 'this' 10 | // scope in class 11 | bool a; 12 | bool b; 13 | class A { 14 | int a; 15 | int b; 16 | A () { 17 | a = 1; 18 | b = a + 1; 19 | this.a = b; 20 | this.b = this.a + 1; 21 | { 22 | string a = toString(this.b); 23 | string b = a; 24 | } 25 | } 26 | }; 27 | int main() { 28 | A a = new A(); 29 | println("too young too simple."); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 16' Xiaoyuan Liu 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | // scope recover 11 | class A { 12 | int a; 13 | }; 14 | int main() { 15 | int x = 1; 16 | { 17 | string x = "gzotpa"; 18 | { 19 | bool x = true; 20 | { 21 | A x = null; 22 | } 23 | if (x) print("gzotpa"); 24 | } 25 | int y = x.length(); 26 | } 27 | x = x + 1; 28 | return x; 29 | } -------------------------------------------------------------------------------- /sema/scope-package/scope-8.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Scope 4 | Author: 16' Jiuqin Zhou 5 | Time: 2019-11-11 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | int main(){ 10 | int i = 0; 11 | 12 | // test forStmt block 13 | for(i = 0; i < 10; ++i){ 14 | string i = ""; 15 | print(i + "\n"); 16 | } 17 | for(i = 0; i < 10; ++i) 18 | int i = 0; 19 | for(i = 0; i < 10; ++i) 20 | for(i = 0; i < 10; ++i) 21 | int i = 0; 22 | { 23 | int i = 0; 24 | } 25 | 26 | // test ifStmt block 27 | if(i == 0){ 28 | string i = ""; 29 | println(i + i); 30 | } 31 | else{ 32 | string i = "-1"; 33 | println(i + i + getString()); 34 | } 35 | if(i == 0) 36 | int i = 0; 37 | else if( i == 0) 38 | if( i == 0) 39 | int i = 0; 40 | else 41 | int i = 0; 42 | { 43 | int i = 0; 44 | } 45 | 46 | // test WhileStmt block 47 | while(toString(i) == "0"){ 48 | string i = "11h"; 49 | int i_ = i.parseInt(); 50 | } 51 | while(i == 0) 52 | int i = 0; 53 | while(i == 0) 54 | while(i == 0) 55 | int i = 0; 56 | { 57 | int i = 0; 58 | } 59 | 60 | return 0; 61 | } -------------------------------------------------------------------------------- /sema/string-package/string-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: String 4 | Author: 15' Caomeng Yao 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | 10 | string[] str_arr = null; 11 | 12 | int main() { 13 | int la = getInt(); 14 | str_arr = new string[la]; 15 | 16 | int i; 17 | int cnt = 0; 18 | for (i = 0; i < la; i++) { 19 | str_arr[i] = getString(); 20 | cnt = cnt + str_arr[i].length(); 21 | } 22 | 23 | string str = ""; 24 | int sum = 0; 25 | for (i = 0; i < la; ++i){ 26 | str = str + str_arr[i].substring(0, str_arr[i].length() - 1); 27 | sum = sum + str_arr[i].ord(0); 28 | } 29 | println(str); 30 | print(toString(sum)); 31 | if (cnt == str.length()) return 0; 32 | 33 | else return 1; 34 | } 35 | -------------------------------------------------------------------------------- /sema/symbol-package/symbol-1.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: 15' Nayun Xu 5 | Time: 2019-10-20 6 | Verdict: Success 7 | Origin Package: Semantic Extended 8 | */ 9 | class A{ 10 | A(){} 11 | B x; 12 | string abc; 13 | int aabc(int abc) { 14 | return abc; 15 | } 16 | }; 17 | 18 | class B { 19 | B(){ 20 | 21 | } 22 | void D() { 23 | 24 | } 25 | A x; 26 | B y; 27 | void t() { 28 | this.D(); 29 | } 30 | }; 31 | 32 | class f{ 33 | 34 | }; 35 | 36 | int main() { 37 | int [ ] ff = new int[1 ]; 38 | f g; 39 | int [ ][ ][ ] fg = new int[4][ ][ ]; 40 | string String; 41 | String = toString(getInt()); 42 | println(toString(String.length())); 43 | } -------------------------------------------------------------------------------- /sema/symbol-package/symbol-2.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: Pikachu 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: _ cannot be the first symbol of identifier 8 | */ 9 | 10 | int main(){ 11 | int _a; 12 | } -------------------------------------------------------------------------------- /sema/symbol-package/symbol-3.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: Pikachu 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: numbers cannot be the first symbol of the identifier 8 | */ 9 | 10 | int main(){ 11 | int 123; 12 | } -------------------------------------------------------------------------------- /sema/symbol-package/symbol-4.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: Pikachu 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: Redefinition of a 8 | */ 9 | 10 | int main(){ 11 | int a; 12 | int a; 13 | } -------------------------------------------------------------------------------- /sema/symbol-package/symbol-5.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: Pikachu 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: Identifier cannot have the same name with reserved name 8 | */ 9 | 10 | int main(){ 11 | int int; 12 | int bool; 13 | bool class; 14 | } -------------------------------------------------------------------------------- /sema/symbol-package/symbol-6.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: Reversed word: this 8 | Origin Package: Semantic Extended 9 | */ 10 | 11 | class A { 12 | void this() { // "this" is a reserved word 13 | return; 14 | } 15 | }; 16 | int main() {} -------------------------------------------------------------------------------- /sema/symbol-package/symbol-7.mx: -------------------------------------------------------------------------------- 1 | /* 2 | Test Package: Sema_Local_Preview 3 | Test Target: Symbol 4 | Author: 15' Lianming Zheng 5 | Time: 2019-10-14 6 | Verdict: Fail 7 | Comment: Reversed word: this 8 | Origin Package: Semantic Extended 9 | */ 10 | 11 | int this; // "this" is a reserved word 12 | 13 | int main() {} -------------------------------------------------------------------------------- /sema/test.mx: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class main{ 5 | int m; 6 | }; 7 | 8 | 9 | int main(){ 10 | class main _main; 11 | } --------------------------------------------------------------------------------