Skip to content

Commit

Permalink
add 499B Lecture
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoshengzhe committed Dec 26, 2014
1 parent e6344aa commit 3b5a6be
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 499B_Lecture/Solution.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <map>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
int n, m;
scanf("%d %d", &n, &m);
char buf1[12];
char buf2[12];
map<string, string> table;
for (int i=0; i < m; ++i) {
scanf("%s %s", buf1, buf2);
string a = buf1;
string b = buf2;
string c = a.size() > b.size() ? b : a;
table[a] = c;
table[b] = c;
}
for (int i=0; i < n; ++i) {
scanf("%s", buf1);
string s = buf1;
if (i <= n-1) {
printf("%s ", table[s].c_str());
} else {
printf("%s\n", table[s].c_str());
}
}
return 0;
}
5 changes: 5 additions & 0 deletions sol.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@

* 算法:如果当前位置为t, 那么跳到下一个精彩时刻[a, b]所需要看的时间为(a - t) % x;加上本身观看时间b - a + 1,所以对于每一组输入,需要观看(a - t) % x + b - a + 1。全部之和即为答案
* 难点:看清题目,以及每次处理完一组后将当前位置置为b+1即可。

## [499B Lecture](499B_Lecture/Solution.cc)

* 算法:用一个map保存每个单词所对应的笔记单词,然后查询map就行
* 难点:string和map操作,不过如果用C++会很简单

0 comments on commit 3b5a6be

Please sign in to comment.