題意:
(from luckycat)
解法:
直接用 STL map or unordered_map。
TAG: ad hoc
注意:
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tittle: 10282 - Babelfish | |
* Author: Cheng-Shih, Wong | |
* Date: 2015/06/03 | |
*/ | |
// include files | |
#include <bits/stdc++.h> | |
using namespace std; | |
// definitions | |
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i ) | |
#define clr(x,v) memset( x, v, sizeof(x) ) | |
typedef unordered_map<string,string> UMSI; | |
// declarations | |
char buf[100]; | |
char a[15], b[15]; | |
// functions | |
// main function | |
int main( void ) | |
{ | |
UMSI dic; | |
// input | |
while( gets(buf) && buf[0] ) { | |
sscanf( buf, "%s%s", a, b ); | |
dic[b] = a; | |
} | |
// solve | |
while( scanf( "%s", a )==1 ) { | |
if( dic.find(a) == dic.end() ) puts("eh"); | |
else puts(dic[a].c_str()); | |
} | |
return 0; | |
} |
沒有留言:
張貼留言
任何意見都樂意傾聽