QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#561916 | #1979. Gratitude | V-ioleT | AC ✓ | 264ms | 60972kb | C++20 | 855b | 2024-09-13 12:53:56 | 2024-09-13 12:53:56 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define mpi make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
const ll mod=1000000007;
const int INF=0x3f3f3f3f;
typedef pair<int,int> P;
inline ll lowbit(ll x){return x&(-x);}
struct node{
string s;
int id;
int num;
}p[maxn];
bool cmp(node a,node b){
if(a.num!=b.num) return a.num>b.num;
return a.id>b.id;
}
map<string,int>mp;
int main(){
int n,k;
cin>>n>>k;
int cnt=1;
getchar();
for(int i=0;i<3*n;i++){
string s;
getline(cin,s);
if(mp[s]==0) mp[s]=cnt++;
int id=mp[s];
p[id].num++;
p[id].id=i;
p[id].s=s;
}
sort(p+1,p+cnt+1,cmp);
for(int i=1;i<=min(k,cnt-1);i++){
cout<<p[i].s<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5ms
memory: 42608kb
input:
1 1 C B A
output:
A
result:
ok single line: 'A'
Test #2:
score: 0
Accepted
time: 7ms
memory: 42668kb
input:
1 2 C B A
output:
A B
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 3ms
memory: 42836kb
input:
1 3 C B A
output:
A B C
result:
ok 3 lines
Test #4:
score: 0
Accepted
time: 3ms
memory: 42644kb
input:
3 1 C B A A B C A B C
output:
C
result:
ok single line: 'C'
Test #5:
score: 0
Accepted
time: 3ms
memory: 42604kb
input:
3 3 C B A A B C A B C
output:
C B A
result:
ok 3 lines
Test #6:
score: 0
Accepted
time: 5ms
memory: 42644kb
input:
3 8 C B A A B C A B C
output:
C B A
result:
ok 3 lines
Test #7:
score: 0
Accepted
time: 7ms
memory: 42584kb
input:
2 3 q w e r t y
output:
y t r
result:
ok 3 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 42660kb
input:
2 6 q w e r t y
output:
y t r e w q
result:
ok 6 lines
Test #9:
score: 0
Accepted
time: 11ms
memory: 42652kb
input:
3 2 A B C B C D C D E
output:
C D
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 7ms
memory: 42668kb
input:
3 3 A B C B C D C D E
output:
C D B
result:
ok 3 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 42864kb
input:
3 5 A B C B C D C D E
output:
C D B E A
result:
ok 5 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 42672kb
input:
3 9 A B C B C D C D E
output:
C D B E A
result:
ok 5 lines
Test #13:
score: 0
Accepted
time: 115ms
memory: 47592kb
input:
33333 99999 21336 54674 65180 6629 63120 30823 92163 80025 50174 67734 879 35964 53935 12142 17604 60250 43015 30063 51541 40979 35454 6328 58642 78108 19028 78847 22766 73250 38610 89274 33675 12046 13983 75354 11269 75620 50011 49208 37912 54086 57755 22472 81134 44117 68226 40713 61097 56983 6639...
output:
19042 92712 60795 76384 24499 43145 12945 3376 7656 15306 79532 22 69151 61515 71569 5130 5795 89216 15511 80114 71141 82394 91849 46552 46246 29443 42195 6044 49931 19323 37134 78803 92422 4353 9070 7773 94490 35583 70515 89667 61457 46601 68936 9004 70491 50484 21666 9155 55315 76935 30732 90162 3...
result:
ok 63322 lines
Test #14:
score: 0
Accepted
time: 19ms
memory: 42592kb
input:
33333 99999 4 74 78 55 8 25 15 6 72 38 82 45 54 56 52 13 2 52 41 71 18 35 78 13 21 52 7 26 40 0 15 41 77 0 43 15 16 40 0 79 19 59 56 94 84 26 73 40 51 94 90 89 75 39 67 63 23 30 84 21 50 12 61 61 74 55 1 16 59 82 33 66 56 78 9 9 88 60 26 50 58 84 39 82 10 71 50 44 36 72 5 29 32 73 95 86 5 64 17 38 5...
output:
26 81 82 58 13 16 77 73 61 66 50 87 69 92 95 96 59 0 43 24 86 1 40 63 54 38 85 27 44 37 28 97 10 29 14 64 4 18 75 79 9 3 89 12 19 41 39 48 49 74 55 56 34 67 83 52 30 7 88 84 15 78 51 5 57 6 45 99 91 62 22 8 93 70 20 90 21 72 17 47 46 31 32 33 25 94 68 2 71 23 11 42 76 36 80 65 60 35 98 53
result:
ok 100 lines
Test #15:
score: 0
Accepted
time: 12ms
memory: 42868kb
input:
33333 99999 0 1 2 2 1 0 2 1 0 1 2 0 0 1 2 0 2 1 1 2 0 0 2 1 2 0 1 2 1 0 1 0 2 0 2 1 1 0 2 1 2 0 2 0 1 0 2 1 2 1 0 1 2 0 0 2 1 2 1 0 0 2 1 0 2 1 2 1 0 0 1 2 0 1 2 0 1 2 2 1 0 2 0 1 0 1 2 0 2 1 2 1 0 0 1 2 0 2 1 0 2 1 0 2 1 2 1 0 0 2 1 0 2 1 2 1 0 2 1 0 2 0 1 1 2 0 2 0 1 0 1 2 0 2 1 2 1 0 2 0 1 0 2 1 ...
output:
2 0 1
result:
ok 3 lines
Test #16:
score: 0
Accepted
time: 11ms
memory: 42868kb
input:
33333 99999 2 0 1 2 0 1 2 1 0 1 0 2 0 1 2 2 1 0 2 1 0 1 2 0 2 1 0 1 0 2 2 0 1 0 2 1 1 2 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 2 1 0 1 0 2 2 0 1 2 1 0 2 0 1 2 1 0 2 1 0 0 1 2 2 1 0 2 1 0 1 2 0 2 0 1 0 2 1 2 0 1 2 0 1 2 0 1 1 2 0 2 0 1 0 2 1 1 2 0 1 2 0 2 1 0 2 0 1 1 0 2 2 1 0 1 2 0 2 1 0 2 1 0 2 0 1 0 2 1 ...
output:
0 2 1
result:
ok 3 lines
Test #17:
score: 0
Accepted
time: 17ms
memory: 42544kb
input:
33333 99999 13 75 80 84 76 98 37 57 92 66 36 73 33 99 96 34 82 78 75 58 89 64 92 90 99 48 65 53 47 71 82 57 31 80 75 58 84 85 76 24 66 62 75 86 68 56 90 20 92 75 72 89 27 14 41 95 57 87 89 52 32 64 78 66 91 73 29 96 62 88 72 63 81 69 43 19 47 31 49 88 75 4 65 93 55 93 83 13 98 88 70 41 94 76 81 74 7...
output:
99 97 96 98 95 93 94 91 89 90 88 92 87 85 86 84 83 79 82 77 80 81 78 76 75 72 74 73 70 67 69 71 68 64 65 66 63 62 60 61 58 56 57 59 55 53 54 51 52 48 49 50 47 46 45 44 40 42 43 41 38 39 35 34 36 37 32 33 30 31 29 27 28 26 25 24 21 23 22 20 19 18 17 16 15 13 14 11 12 10 9 7 8 6 5 4 2 3 1 0
result:
ok 100 lines
Test #18:
score: 0
Accepted
time: 30ms
memory: 42656kb
input:
33333 99999 783 853 939 955 662 776 776 907 345 764 671 849 994 680 958 829 991 945 589 871 559 907 60 790 949 863 367 937 956 448 886 835 757 563 476 883 865 161 887 685 954 388 792 970 916 852 854 927 820 267 911 548 976 488 759 974 986 673 615 661 809 582 978 496 676 375 543 712 827 797 735 814 9...
output:
949 895 978 982 989 972 981 967 917 913 996 974 927 997 977 954 961 931 936 998 932 963 950 930 911 960 994 987 934 999 958 922 856 943 951 919 945 826 976 907 992 988 993 890 952 937 969 862 929 975 971 903 940 858 985 979 861 872 986 899 916 933 925 915 905 854 921 828 942 902 910 926 956 868 970 ...
result:
ok 996 lines
Test #19:
score: 0
Accepted
time: 180ms
memory: 52952kb
input:
33333 99999 nhxuwiy ksrgisczhqbptjlwpgsiqhcobiabtadklkslulwp wiuzbkomrvnqqjrrtjsghnqqhgnojxcyqjwlxpraymifqyizg ujvscflrbsdvocfpvxqhi skpthjfhbpzzektsjqpl pfpkco rzitpvvczobgaluiskgchqryqakqrahpekraujteehxukvgcz nhxuwiy ksrgisczhqbptjlwpgsiqhcobiabtadklkslulwp dzilpjqoobmerirmjhqseuxambeamznrfn pts...
output:
aou rckckqjfowys tsnfx olhsslmrlyotqloyybqvkb ft zayzdizaibmcntctnu er jnasoyfgfobjnveqrzgjtgfxel rzitpvvczobgaluiskgchqryqakqrahpekraujteehxukvgcz rqcwnifkguyzolcyinhuunsbjwzdlxsqgrfehctrxdsxmeaub edxgmnojftqcnwhhi bifnsfhwzyybg nnomnsgkudvrfkfac aocoofidff juy cplopnui qonkkwiqrelytmphrykfpaxx ...
result:
ok 49957 lines
Test #20:
score: 0
Accepted
time: 264ms
memory: 60972kb
input:
33333 99999 nhxuwiy ksrgisczhqbptjlwpgsiqhcobiabtadklkslulwp wiuzbkomrvnqqjrrtjsghnqqhgnojxcyqjwlxpraymifqyizg ujvscflrbsdvocfpvxqhi skpthjfhbpzzektsjqpl pfpkco rzitpvvczobgaluiskgchqryqakqrahpekraujteehxukvgcz yddzilpjqoobmerirmjhqseuxambeamznrfn ptskrxbmvabf nhxuwiy ksrgisczhqbptjlwpgsiqhcobiabt...
output:
z bdmlqykuljsozso bhnebkcjvi awaf ersylzij ckama lgoiwqjscpazrgpjqujjgtbofnnqsyjrrkgjggmxhxmiydchk cpywlqzeo wltqvjwxarihybfeuhisrhgiav n wqbeuclot qxiiwn zayzdizaibmcntctnu er jnasoyfgfobjnveqrzgj lwycy yfymzeckwgbjohdrmehajdnjopthl vzmpwhyiqgs h ylmjanoiaujwxexd ptlxddaigtcduxjjtp hrsrp ttuhus i...
result:
ok 90102 lines