文章

28

粉丝

0

获赞

480

访问

10.3k

头像
查找学生信息 题解:
P1177 北京大学上机题
发布于2026年2月10日 14:14
阅读数 184

#include <iostream>

#include <vector>

using namespace std;

int main(){

  int N,M;

  while(cin>>N>>M){

    vector<int> reader; //下标是读者,后面输出的时候一一对应

    vector<int> count(M+1,0); //下标是书籍id,用于计数有多少人读这本书

    int book;

    for(int i=0;i<N;i++){

      cin>>book;

      reader.push_back(book);

      count[book]++;

    }

    for(int r:reader){

      if(count[r]==1)cout<<"BeiJu"<<"\n";

      else if(count[r]>1)cout<<count[r]-1<<"\n";

    }

  }

  return 0;

}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发