标签:dfa print zrc color ejs ted asd vhdl alt
两次快排记录一下每个点上下左右能到哪个点就好了...
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cstdlib> 6 #include<cmath> 7 using namespace std; 8 struct data{ 9 int x,y,z; 10 }po[100005]; 11 int n,m,f[100002][5],a; 12 string qwq; 13 bool comp1(const struct data a,const struct data b){ 14 if (a.x<b.x) return 1; 15 if (a.x==b.x) if (a.y<b.y) return 1; 16 return 0; 17 } 18 bool comp2(const struct data a,const struct data b){ 19 if (a.y<b.y) return 1; 20 if (a.y==b.y) if (a.x<b.x) return 1; 21 return 0; 22 } 23 int main(){ 24 freopen("tratincice.in","r",stdin); 25 freopen("tratincice.out","w",stdout); 26 scanf("%d%d",&n,&m); 27 int x,y; 28 for (int i=1;i<=n;i++){ 29 scanf("%d%d",&po[i].x,&po[i].y); 30 po[i].z=i; 31 if ((po[i].x==0)&&(po[i].y==0)) a=i; 32 } 33 cin>>qwq; 34 sort(po+1,po+1+n,comp1); 35 for (int i=1;i<=n;i++){ 36 if ((po[i].x==po[i-1].x)&&(po[i].y<po[i-1].y)) {f[po[i].z][0]=po[i-1].z; f[po[i-1].z][1]=po[i].z;} 37 if ((po[i].x==po[i-1].x)&&(po[i].y>po[i-1].y)) {f[po[i].z][1]=po[i-1].z; f[po[i-1].z][0]=po[i].z;} 38 } 39 sort(po+1,po+1+n,comp2); 40 for (int i=1;i<=n;i++){ 41 if ((po[i].y==po[i-1].y)&&(po[i].x<po[i-1].x)) {f[po[i].z][2]=po[i-1].z; f[po[i-1].z][3]=po[i].z;} 42 if ((po[i].y==po[i-1].y)&&(po[i].x>po[i-1].x)) {f[po[i].z][3]=po[i-1].z; f[po[i-1].z][2]=po[i].z;} 43 44 } 45 for (int i=0;i<m;i++){ 46 x=(int)qwq[i]-(int)‘A‘; 47 if (x==17) a=f[a][2]; 48 else if (x==20) a=f[a][0]; 49 else if (x==3) a=f[a][1]; 50 else if (x==11) a=f[a][3]; 51 } 52 for (int i=0;i<=n;i++) 53 if (po[i].z==a){ 54 printf("%d %d",po[i].x,po[i].y); 55 return 0; 56 } 57 }
标签:dfa print zrc color ejs ted asd vhdl alt
原文地址:http://www.cnblogs.com/Lanly/p/7299730.html