国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

pat甲級 1022 Digital Library

這篇具有很好參考價值的文章主要介紹了pat甲級 1022 Digital Library。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query from a reader, you are supposed to output the resulting books, sorted in increasing order of their ID's.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer?N?(≤104) which is the total number of books. Then?N?blocks follow, each contains the information of a book in 6 lines:

  • Line #1: the 7-digit ID number;
  • Line #2: the book title -- a string of no more than 80 characters;
  • Line #3: the author -- a string of no more than 80 characters;
  • Line #4: the key words -- each word is a string of no more than 10 characters without any white space, and the keywords are separated by exactly one space;
  • Line #5: the publisher -- a string of no more than 80 characters;
  • Line #6: the published year -- a 4-digit number which is in the range [1000, 3000].

It is assumed that each book belongs to one author only, and contains no more than 5 key words; there are no more than 1000 distinct key words in total; and there are no more than 1000 distinct publishers.

After the book information, there is a line containing a positive integer?M?(≤1000) which is the number of user's search queries. Then?M?lines follow, each in one of the formats shown below:

  • 1: a book title
  • 2: name of an author
  • 3: a key word
  • 4: name of a publisher
  • 5: a 4-digit number representing the year

Output Specification:

For each query, first print the original query in a line, then output the resulting book ID's in increasing order, each occupying a line. If no book is found, print?Not Found?instead.

Sample Input:

3
1111111
The Testing Book
Yue Chen
test code debug sort keywords
ZUCS Print
2011
3333333
Another Testing Book
Yue Chen
test code sort keywords
ZUCS Print2
2012
2222222
The Testing Book
CYLL
keywords debug book
ZUCS Print2
2011
6
1: The Testing Book
2: Yue Chen
3: keywords
4: ZUCS Print
5: 2011
3: blablabla

Sample Output:

1: The Testing Book
1111111
2222222
2: Yue Chen
1111111
3333333
3: keywords
1111111
2222222
3333333
4: ZUCS Print
1111111
5: 2011
1111111
2222222
3: blablabla
Not Found

代碼長度限制

16 KB

時間限制

1200 ms

內(nèi)存限制

64 MB文章來源地址http://www.zghlxwxcb.cn/news/detail-851962.html

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
const int N = 10010;
int n;
int m;
struct st {
    string id;
    string title;
    string author;
    string words;
    string publisher;
    string year;
}q[N];

bool cmp(st a, st b) {
    return a.id < b.id;
}
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> q[i].id;
        getchar();
        getline(cin, q[i].title);
        getline(cin, q[i].author);
        getline(cin, q[i].words);
        getline(cin, q[i].publisher);
        getline(cin, q[i].year);
    }
    sort(q + 1, q + 1 + n, cmp);
    cin >> m;
    for (int i = 1; i <= m; i++) {
        int w;
        char op;
        string s;
        cin >> w >> op;
        getchar();
        getline(cin, s);
        if (w == 1) {
            bool flag = false;
            cout << w << op << " " << s << endl;
            for (int i = 1; i <= n; i++) {
                if (q[i].title == s) {
                    cout << q[i].id << endl;
                    flag = true;
                }
            }
            if (!flag) cout << "Not Found" << endl;
        }
        if (w == 2) {
            cout << w << op << " " << s << endl;
            bool flag = false;
            for (int i = 1; i <= n; i++) {
                if (q[i].author == s) {
                    flag = true;
                    cout << q[i].id << endl;
                }
            }
            if (!flag) cout << "Not Found" << endl;
        }
        if (w == 3) {
            cout << w << op << " " << s << endl;
            bool flag = false;;
            for (int i = 1; i <= n; i++) {
                if (q[i].words.find(s) !=-1) {
                    flag = true;
                    cout << q[i].id << endl;
                }
            }
            if (!flag) cout << "Not Found" << endl;
        }
        if (w == 4) {
            cout << w << op << " " << s << endl;
            bool flag = false;
            for (int i = 1; i <= n; i++) {
                if (q[i].publisher == s) {
                    flag = true;
                    cout << q[i].id << endl;
                }
            }
            if (!flag) cout << "Not Found" << endl;
        }
        if (w== 5) {
            cout << w << op << " " << s << endl;
            bool flag = false;
            for (int i = 1; i <= n; i++) {
                if (q[i].year == s) {
                    flag = true;
                    cout << q[i].id << endl;
                }
            }
            if (!flag) cout << "Not Found" << endl;
        }
    }
    return 0;
}

到了這里,關(guān)于pat甲級 1022 Digital Library的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 1083 List Grades (PAT甲級)

    Given a list of?N?student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval. Input Specification: Each input file contains one test case. Each case is given in the following format: where? name[i] ?and? ID[i

    2024年02月08日
    瀏覽(19)
  • 1028 List Sorting (PAT甲級)

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, the first line contains two integers?N?(≤105) and?C, where?N?is the number of records and?C?is the column that you are supposed to sort the records with. Then?N?lines follow, eac

    2024年02月15日
    瀏覽(16)
  • 1021 Deepest Root (PAT甲級)

    1021. Deepest Root (25)-PAT甲級真題(圖的遍歷,dfs,連通分量的個數(shù))_柳婼的博客-CSDN博客 柳婼的解法在這里,兩次dfs,還是挺好玩的。 我的解法比較暴力,就是先用并查集算連通分量(這個其實還是dfs來算會更方便),如果只有一個連通分量,那deepest root一定在僅有一條arc的

    2024年02月15日
    瀏覽(16)
  • 1114 Family Property (PAT甲級)

    This time, you are supposed to help us collect the data for family-owned property. Given each person\\\'s family members, and the estate(房產(chǎn))info under his/her own name, we need to know the size of each family, and the average area and number of sets of their real estate. Input Specification: Each input file contains one test case. For each case, the fir

    2024年02月06日
    瀏覽(19)
  • 1072 Gas Station (PAT甲級)

    A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map of the city and several candidate locations for the gas station, you are supposed to give the best recommendatio

    2024年02月09日
    瀏覽(22)
  • 1111 Online Map (PAT甲級)

    這道題我讀題不仔細(xì)導(dǎo)致踩了個大坑,一個測試點過不了卡了好幾個小時:第二個dijkstra算法中,題目要求是“In case the fastest path is not unique, output the one that passes through the fewest intersections”,我卻想當(dāng)然地認(rèn)為在fastest path is not unique的時候,判斷標(biāo)準(zhǔn)是最短距離…… Input our

    2024年02月07日
    瀏覽(16)
  • 菜鳥記錄PAT甲級1003--Emergency

    菜鳥記錄PAT甲級1003--Emergency

    久違的PAT,由于考研408數(shù)據(jù)結(jié)構(gòu)中有一定需要,同時也是對先前所遺留的競賽遺憾進行一定彌補 ,再次繼續(xù)PAT甲級1003.。 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l

    2023年04月13日
    瀏覽(97)
  • PAT 甲級【1007 Maximum Subsequence Sum】

    本題是考察動態(tài)規(guī)劃與java的快速輸入: max[i]表示第i個結(jié)尾的最大的連續(xù)子串和。b begin[i]表示第[begin[i],i]為最大和的開始位置 超時代碼: 未超時: 能用動態(tài)規(guī)劃解決的問題,需要滿足三個條件:最優(yōu)子結(jié)構(gòu),無后效性和子問題重疊。 具有最優(yōu)子結(jié)構(gòu)也可能是適合用貪心的

    2024年02月08日
    瀏覽(24)
  • 1074 Reversing Linked List (PAT甲級)

    Given a constant?K?and a singly linked list?L, you are supposed to reverse the links of every?K?elements on?L. For example, given?L?being 1→2→3→4→5→6, if?K=3, then you must output 3→2→1→6→5→4; if?K=4, you must output 4→3→2→1→5→6. Input Specification: Each input file contains one test case. For each case, the first line

    2024年02月09日
    瀏覽(15)
  • PAT 甲級1005【1005 Spell It Right】

    PAT 甲級1005【1005 Spell It Right】

    用JAVA可以用BigInteger解決。 ? ? ? 太長不看版:結(jié)尾自取模板…… 高精度計算(Arbitrary-Precision Arithmetic),也被稱作大整數(shù)(bignum)計算,運用了一些算法結(jié)構(gòu)來支持更大整數(shù)間的運算(數(shù)字大小超過語言內(nèi)建整型)。 高精度問題包含很多小的細(xì)節(jié),實現(xiàn)上也有很多講究。

    2024年02月08日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包