标签:lis com moved igp script dog table pst out
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 44545 | Accepted: 18803 |
Description
Input
Output
Sample Input
dog ogday cat atcay pig igpay froot ootfray loops oopslay atcay ittenkay oopslay
Sample Output
cat eh loops
Hint
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; struct node{ char s1[25],s2[25]; }a[N]; int n; int cmp(node a,node b){ return strcmp(a.s2,b.s2)<0; //感觉好厉害(;′д`)ゞ } int main(){ n=0; char str[50]; while(gets(str)){ if(str[0]==‘\0‘) break; sscanf(str,"%s%s",a[n].s1,a[n].s2); //好厉害(;′д`)ゞ n++; } sort(a,a+n,cmp); while(gets(str)){ int l=0,r=n,mid,flag=1; while(l<=r){ //二分 mid=(l+r)>>1; if(strcmp(str,a[mid].s2)==0){ printf("%s\n",a[mid].s1); flag=0; break; } else if(strcmp(str,a[mid].s2)<0) r=mid-1; else l=mid+1; } if(flag) printf("eh\n"); } return 0; }
==
标签:lis com moved igp script dog table pst out
原文地址:http://www.cnblogs.com/ZERO-/p/7128855.html