1818. Achievement Conversion Constraints
Time limit:5 secs, Memory limit:32 MB
Description
Save the student's name and score, then check the student's grade by name.
Enter the score for percentile, convert it to the corresponding level, and the specific conversion rules are as follows:
90~100 is A;
80~89 is B;
70~79 is C;
60~69 is D;
0~59 to E;
Input
Enter more than one set of data. Number of first-action data groups T.
For each set of data, the first row contains two integers n (1<n<=15000) and M (1<m<=10000), n indicates the number of students, and M indicates the number of queries. Next n lines, each row contains the name and score of a student. Next m line, each line a string, indicating the student's name.
Note: The data may have a duplicate name for the student, whichever is the last occurrence.
Output
For each query, output a line that represents the student's grade. If the input data is not in the 0~100 range, output one line: "Score is error!".
Sample Input
3cigam 56cxw 67xzz 100daxia 123daxiacigamxzz
Sample Output
Score is error! Ea
1.33s:
#include <map> #include <string> #include <iostream> #include <utility>using namespace std;void print (int a) {if (A < 0 | | a >) cout << "score is error!" << Endl; else if (0 <= a && a <) cout << "E" << Endl; else if (<= a && a <) cout << "D" << Endl; else if (<= a && a <) cout << "C" << Endl; else if (<= a && a <) cout << "B" << Endl; else if (<= a && a <=) cout << "a" << Endl;} int main () {Std::ios::sync_with_stdio (false); int Case_num, Man_num, Ques_num, temp_p; Cin >> Case_num; while (case_num--) {string name; Map<string, int> m_m; Map<string, int>:: iterator mm; CIN >> Man_num >> Ques_num; while (man_num--) { CIN >> name >> temp_p; if (m_m.find (name) = = M_m.end ()) M_m.insert (pair<string, int> (name, temp_p)); Else (*m_m.find (name)). Second = temp_p; } while (ques_num--) {cin >> name; Print (M_m[name]); }} return 0;}
Sicily 1818. Score Conversion