nowcoder练习赛28

  https://www.nowcoder.com/acm/contest/200#question

  最近突然找到了打比赛的乐趣,于是参加了这场比赛.

  

  生日宴会:https://www.nowcoder.com/acm/contest/200/A

  按照题意模拟,没什么好说的.

  
 1 # include <cstdio>
 2 # include <iostream>
 3 # include <cstring>
 4 # include <cmath>
 5 # include <algorithm>
 6 # include <string>
 7 # define R register int
 8 
 9 using namespace std;
10 
11 const int maxn=1005;
12 char name[maxn][13];
13 int n,m,dat,x,y;
14 struct nod
15 {
16     int val,k;
17 }id[1240][maxn];
18 int h[1240];
19 
20 bool cmp (nod a,nod b)
21 {
22     return a.val<b.val;
23 }
24 
25 int main()
26 {
27     scanf("%d%d",&n,&m);
28     for (R i=1;i<=n;++i)
29     {
30         scanf("%s",name[i]);
31         scanf("%d",&dat);
32         id[dat%10000][ ++h[dat%10000] ].k=i;
33         id[dat%10000][ h[dat%10000] ].val=dat/10000;
34     }
35     for (R i=0;i<=1231;++i)
36         sort(id[i]+1,id[i]+1+h[i],cmp);
37     for (R i=1;i<=m;++i)
38     {
39         scanf("%d%d",&x,&y);
40         printf("%s\n",name[ id[y][x].k ]);    
41     }
42     return 0;
43 }
A

 

  数据结构:https://www.nowcoder.com/acm/contest/200/B

  题意概述:

  

猜你喜欢

转载自www.cnblogs.com/shzr/p/9751719.html