POJ 2503 Babelfish,poj2503babelfish

來源:互聯網
上載者:User

POJ 2503 Babelfish,poj2503babelfish

表示剛剛做出來 就發現不能提交了 好悲催= =

傷心難過痛哭流涕%>_<%

Babelfish
Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 31630   Accepted: 13613

Description

You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.

Input

Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.

Output

Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".

Sample Input

dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay

Sample Output

catehloops

Hint

Huge input and output,scanf and printf are recommended.



#include <iostream>#include <string>#include <map>#include <stdio.h>#include <cstring>using namespace std;int main(){map <string ,bool >appear;map <string ,string>printf;char s[40],sa[20],sb[20];string f;string english;    while (gets(s)){if (s[0]=='\0')break;int len1;int len=strlen(s);for(len1=0;len1<len;len1++)if(s[len1]==' ')break;int i;for(i=0;i<len1;i++)sa[i]=s[i];sa[len1]='\0';int k=0;for(i=len1+1;i<len;i++)sb[k++]=s[i];sb[k]='\0';english=sa;f=sb;appear[f]=true;printf[f]=english;}string s1;while(cin>>s1){if(appear[s1]==true)cout<<printf[s1]<<endl;elsecout<<"eh"<<endl;}    return 0;}/*dog ogdaycat atcaypig igpayfroot ootfrayloops oopslayatcayittenkayoopslay*/





poj 2503 RE,更改,高分,AC後追加不是問題

過客!
 
poj 2503 輸入問題用pascal怎解決

type rec=record x,y:string;end;var a:array[0..100000] of rec; n,i,j:longint; s,t:string;procedure sort(m,n:longint);var x:string; t:rec; i,j:longint;begin x:=a[(m+n) shr 1].x; i:=m; j:=n; repeat while a[i].x<x do inc(i); while a[j].x>x do dec(j); if i<=j then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; inc(i); dec(j); end; until i>j; if i<n then sort(i,n); if m<j then sort(m,j);end;function find(s:string;L,r:longint):longint;var m:longint;begin m:=(L+r) shr 1; if a[m].x=s then exit(m); if L>=r then exit(0); if a[m].x<s then exit(find(s,m+1,r)); exit(find(s,L,m-1));end;begin a[0].y:='eh'; n:=0; while true do begin readln(s); if s='' then break; inc(n); t:=copy(s,1,pos(' ',s)-1); delete(s,1,pos(' ',s)); a[n].x:=s; a[n].y:=t; end; sort(1,n); while not eof do begin readln(s); writeln(a[find(s,1,n)].y); end;end.你可以參考我的AC程式

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.