POJ openjudge 个人测试 #1
刚回来事情比较多。。2h一半时间都没在
1496.Word Index
就是一个类全排列的搜索,直接得出每个串的序号
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 48 49 50 |
#include<set> #include<map> #include<ctime> #include<queue> #include<cmath> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int top,id; string q[1000005]; map<string,int> mp; void dfs(int x,string t,int now) { if(x==0) { q[++top]=t; return; } for(int i=now+1;i<26;i++) dfs(x-1,t+(char)(i+'a'),i); } int main() { for(int i=1;i<=5;i++) { top=0; dfs(i,"",-1); sort(q+1,q+top+1); for(int j=1;j<=top;j++) mp[q[j]]=++id; } string t; while(cin>>t) printf("%d\n",mp[t]); return 0; } |
1586.Three Sides Make a Triangle
用勾股定理判三角形形状的
输入比较坑爹,只有一个-1终止输入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-1 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } double d[5]; struct P{ double x,y; friend double dis2(P a,P b){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } }p[5]; bool equ(double a,double b) { return fabs(a-b)<eps; } int main() { while(scanf("%lf%lf%lf%lf%lf%lf",&p[1].x,&p[1].y,&p[2].x,&p[2].y,&p[3].x,&p[3].y)) { if(p[1].x==-1&&p[1].y==inf) { puts("End of Output"); return 0; } p[4]=p[1]; for(int i=1;i<=3;i++)d[i]=sqrt(dis2(p[i],p[i+1])); sort(d+1,d+4); if(d[1]+d[2]<=d[3]+eps)puts("Not a Triangle"); else { if(equ(d[1],d[3]))printf("Equilateral "); else if(equ(d[1],d[2])||equ(d[2],d[3]))printf("Isosceles "); else printf("Scalene "); for(int i=1;i<=3;i++)d[i]=dis2(p[i],p[i+1]); sort(d+1,d+4); if(d[1]+d[2]>d[3]+eps)puts("Acute"); else if(equ(d[1]+d[2],d[3]))puts("Right"); else puts("Obtuse"); } p[1].y=inf; } return 0; } |
1071.Illusive Chase
搜索wa了n发无语QAQ
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
#include<set> #include<map> #include<cmath> #include<ctime> #include<queue> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define mod 1000000007 #define inf 1000000000 #define eps 1e-1 #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int n,m,T,top; int u[10005],v[10005],d[10005],a[105][105]; char ch[10005][2]; int xx[4]={0,0,-1,1},yy[4]={1,-1,0,0};//RLUD int dfs(int x,int y,int now) { if(x>n||y>m||x<1||y<1)return 0; if(a[x][y])return 0; if(now==top)return 1; for(int i=1;i<=v[now];i++) { int nx=x+xx[d[now]]*i,ny=y+yy[d[now]]*i; if(nx>n||ny>m||nx<1||ny<1)return 0; if(a[nx][ny])return 0; if(i>=u[now])if(dfs(nx,ny,now+1))return 1; } return 0; } int main() { T=read(); while(T--) { n=read();m=read(); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) a[i][j]=read(); top=0; while(1) { top++; u[top]=read();v[top]=read(); if(!u[top]&&!v[top])break; scanf("%s",ch[top]+1); if(ch[top][1]=='R')d[top]=0; else if(ch[top][1]=='L')d[top]=1; else if(ch[top][1]=='U')d[top]=2; else d[top]=3; } int ans=0; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(dfs(i,j,1)) ans++; printf("%d\n",ans); } return 0; } |
为啥我刚发出去就提示是2min前= =
1496乱码了哦