c射线是什么Week4 CSP-M1 C - 可怕的宇宙射线

新闻资讯2026-04-23 14:20:03
 1 /* 用set的好处:最后不必遍历整个数组; 可以存负数的边 ;*/
 2 #include <cstdio>
 3 #include <iostream>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <set>
 7 using namespace std;
 8 struct point
 9 
16 };
17 set <point> S;
18 int a[40];
19 int n,ans=0;
20 //右,右下,下,左下,左,左上,上,右上 
21 //最初dir=6,向上走 
22 int dx[]={ +1, +1,  0, -1, -1, -1,  0, +1};
23 int dy[]={  0, -1, -1, -1,  0, +1, +1, +1};
24 void dfs(int dir,int num,int x,int y)   //从dir方向分裂,该分裂是第num次分裂,走a[num]步,分裂的点是x,y 
25  ); 
40     }
41     
42     set<point> St; 
43     for(auto t:S)   //遍历集合中的每一个点,生成对称点 
44     {
45         //判断这一层是通过哪个方向的分裂进入到下一层的
46         switch(r%4)
47         {
48             case 1: St.insert( { t.x,y-t.y+y } ); break;  //关于y=y对称  
49             
50             case 2: St.insert( { x+y-t.y,x+y-t.x } ); break;  //关于y=-x 对称 没问题 
51             
52             case 3: St.insert( { x+(x-t.x),t.y } ); break;   //关于x=x对称 
53             
54             case 0: St.insert( { x+t.y-y,y+t.x-x } ); break;  //关于y=x对称 
55         }
56     }
57     S.insert( St.begin(),St.end() );
58     
59 }
60 int main()
61 {
62 //    freopen("a.in","r",stdin); 
63     cin>>n;
64     for(int i=1;i<=n;i++)
65         scanf("%d",a+i);
66     
67     dfs(6,2,5000,5000);
68     for(int i=0;i<a[1];i++)
69     {
70         S.insert( {5000,5000-i} );
71      } 
72     cout<<S.size()<<endl;   //有可能起点也被填充了多次,所以 
73     return 0;
74 }