zoukankan      html  css  js  c++  java
  • PAT1039

    卡两样东西,一个是string的map,另一个是cin,cout

    谢谢PAT让我感受到了OI的风采

     1 #include <iostream>
     2 #include <vector>
     3 #include <string>
     4 #include <fstream>
     5 #include <map>
     6 #include <algorithm>
     7 
     8 using namespace std;
     9 
    10 //#define OJ
    11 
    12 #ifdef OJ
    13 #define fin cin
    14 #endif
    15 
    16 int hash_str(const char *str){
    17     return (str[0] - 'A') * 26 * 26 * 10 + (str[1] - 'A') * 26 * 10 + (str[2] - 'A') * 10 + (str[3] - '0');
    18 }
    19 
    20 vector<int> student_course[26 * 26 * 26 * 10];
    21 
    22 int main(){
    23 #ifndef OJ
    24     ifstream fin("in.data");
    25 #endif
    26 
    27     ios::sync_with_stdio(NULL);
    28 
    29     int N, K;
    30     fin >> N >> K;
    31 
    32     char name[5];
    33 
    34     for (int i = 0; i < K; i++){
    35         int idx, num;
    36         fin >> idx >> num;
    37 
    38         for (int j = 0; j < num; j++){
    39             fin >> name;
    40             student_course[hash_str(name)].push_back(idx);
    41         }
    42     }
    43 
    44     for (int i = 0; i < N; i++){
    45         fin >> name;
    46 
    47         vector<int> &course_idx = student_course[hash_str(name)];
    48         sort(course_idx.begin(), course_idx.end());
    49 
    50         printf("%s %d", name, course_idx.size());
    51         for (int j = 0; j < course_idx.size(); j++){
    52             printf(" %d", course_idx[j]);
    53         }
    54 
    55         printf("
    ");
    56     }
    57 
    58     return 0;
    59 }
  • 相关阅读:
    iPhone 6和iPhone 6 plus的AV Foundation框架特性
    实时人脸识别
    相机 视频流数据--预览 拍照 变焦
    AVCaptureStillImageOutput获取静态图像
    jquery返回上一页面
    js闭包
    一些正则匹配
    嵌套 click 第二层 click会叠加 导致 触发 多次
    QPS
    除了汉字全部过滤
  • 原文地址:https://www.cnblogs.com/EpisodeXI/p/4098119.html
Copyright © 2011-2022 走看看