Posted on 2007-05-03 10:32 
oyjpart 阅读(980) 
评论(2)  编辑 收藏 引用  所属分类: 
ACM/ICPC或其他比赛 
			 
			
		 
		今天集训队出了一些题目做
看到一个2900 想了想 什么线段相交之类的做法 觉得还是挺复杂的
闲来无聊 翻翻status 突然看到alpc12!
顿觉十分惊讶 一看 是很久以前做过的题目了 仔细查查 竟然是我在PKU上做的第五道题 。。。 一看 那时候还不知道多test case怎么处理 居然把所有的答案保存一下 一次输出 而且程序里面 还有一堆goto语句。。faint
贴出来纪念一下那个纯真的年代
Source
Problem Id:2900  User Id:alpc12 
Memory:7904K  Time:265MS
Language:C++  Result:Accepted
    - Source
    
    
      1 #include <iostream> #include <iostream>
 2 #include <string> #include <string>
 3 using namespace std; using namespace std;
 4 int d[1001][1001]; //0空白 1一次 2两次 int d[1001][1001]; //0空白 1一次 2两次
 5 enum dr{EM, UL, UR, DL, DR};//empty & not available enum dr{EM, UL, UR, DL, DR};//empty & not available
 6 dr dir[1001][1001]; dr dir[1001][1001];
 7 int main() int main()
 8 { {
 9 int t,a,b,x,y; int t,a,b,x,y;
 10 string indrt; string indrt;
 11 int i,j,k; int i,j,k;
 12 scanf("%d",&t); scanf("%d",&t);
 13 int *count = new int[t]; int *count = new int[t];
 14 for (i=0; i<t; i++) for (i=0; i<t; i++)
 15 count[i] = 0; count[i] = 0;
 16 for (i=0; i<t; i++) //input for (i=0; i<t; i++) //input
 17 { {
 18 for(j=1; j<=a; j++) //initiate for(j=1; j<=a; j++) //initiate
 19 { {
 20 for(k=1; k<=b; k++) for(k=1; k<=b; k++)
 21 { {
 22 d[j][k] = 0; d[j][k] = 0;
 23 dir[j][k] = EM; dir[j][k] = EM;
 24 } }
 25 } }
 26 scanf("%d%d%d%d",&a,&b,&x,&y); scanf("%d%d%d%d",&a,&b,&x,&y);
 27 d[x][y] = 1; d[x][y] = 1;
 28 cin >> indrt; cin >> indrt;
 29 if(indrt=="UL") dir[x][y] =UL; if(indrt=="UL") dir[x][y] =UL;
 30 if(indrt=="UR") dir[x][y] =UR; if(indrt=="UR") dir[x][y] =UR;
 31 if(indrt=="DL") dir[x][y] =DL; if(indrt=="DL") dir[x][y] =DL;
 32 if(indrt=="DR") dir[x][y] =DR; if(indrt=="DR") dir[x][y] =DR;
 33 int u,l; int u,l;
 34 dr father = dir[x][y]; dr father = dir[x][y];
 35 for(j=0; ;j++) for(j=0; ;j++)
 36 { {
 37 father = dir[x][y]; father = dir[x][y];
 38 switch(father) switch(father)
 39 { {
 40 case UL: u=-1; l=-1; break; case UL: u=-1; l=-1; break;
 41 case UR: u=-1; l=1;  break; case UR: u=-1; l=1;  break;
 42 case DL: u=1; l=-1;  break; case DL: u=1; l=-1;  break;
 43 case DR: u=1; l=1;   break;//忘了break case DR: u=1; l=1;   break;//忘了break
 44 } }
 45 x+=u; x+=u;
 46 y+=l; y+=l;
 47 if (d[x][y]==2) goto print; if (d[x][y]==2) goto print;
 48 if (d[x][y]==1) if (d[x][y]==1)
 49 { {
 50 dr temp = dir[x][y]; dr temp = dir[x][y];
 51 d[x][y] = 2; d[x][y] = 2;
 52 count[i]++; count[i]++;
 53 dir[x][y] = father; dir[x][y] = father;
 54 if(x==1) if(x==1)
 55 { {
 56 if (father == UL) if (father == UL)
 57 dir[x][y] = DL; dir[x][y] = DL;
 58 else else
 59 dir[x][y] = DR; dir[x][y] = DR;
 60 } }
 61 if(x==a) if(x==a)
 62 { {
 63 if (father == DL) if (father == DL)
 64 dir[x][y] = UL; dir[x][y] = UL;
 65 else else
 66 dir[x][y] = UR; dir[x][y] = UR;
 67 } }
 68 if(y==1) if(y==1)
 69 { {
 70 if (father == UL) if (father == UL)
 71 dir[x][y] = UR; dir[x][y] = UR;
 72 else else
 73 dir[x][y] = DR; dir[x][y] = DR;
 74 } }
 75 if(y==b) if(y==b)
 76 { {
 77 if (father == UR) if (father == UR)
 78 dir[x][y] = UL; dir[x][y] = UL;
 79 else else
 80 dir[x][y] = DL; dir[x][y] = DL;
 81 } }
 82 if((x==1||x==a) && (y==1)||(y==b)) if((x==1||x==a) && (y==1)||(y==b))
 83 goto print; goto print;
 84 if(temp == dir[x][y]) if(temp == dir[x][y])
 85 { {
 86 goto print; goto print;
 87 } }
 88 }//if }//if
 89 if(d[x][y]==0) if(d[x][y]==0)
 90 { {
 91 d[x][y] = 1; d[x][y] = 1;
 92 dir[x][y] = father; dir[x][y] = father;
 93 if(x==1) if(x==1)
 94 { {
 95 if (father == UL) if (father == UL)
 96 dir[x][y] = DL; dir[x][y] = DL;
 97 else else
 98 dir[x][y] = DR; dir[x][y] = DR;
 99 } }
 100 if(x==a) if(x==a)
 101 { {
 102 if (father == DL) if (father == DL)
 103 dir[x][y] = UL; dir[x][y] = UL;
 104 else else
 105 dir[x][y] = UR; dir[x][y] = UR;
 106 } }
 107 if(y==1) if(y==1)
 108 { {
 109 if (father == UL) if (father == UL)
 110 dir[x][y] = UR; dir[x][y] = UR;
 111 else else
 112 dir[x][y] = DR; dir[x][y] = DR;
 113 } }
 114 if(y==b) if(y==b)
 115 { {
 116 if (father == UR) if (father == UR)
 117 dir[x][y] = UL; dir[x][y] = UL;
 118 else else
 119 dir[x][y] = DL; dir[x][y] = DL;
 120 } }
 121 if(((x==1)||(x==a)) && ((y==1)||(y==b))) if(((x==1)||(x==a)) && ((y==1)||(y==b)))
 122 { {
 123 goto print; goto print;
 124 } }
 125 }//if }//if
 126 }//if }//if
 127 print:    ; print:    ;
 128 } }
 129 for (i=0; i<t; i++) for (i=0; i<t; i++)
 130 printf("%d\n",count[i]); printf("%d\n",count[i]);
 131 return 0; return 0;
 132 } }
 133