25: Tourist

暴力

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 string str[111];
 5 vector<string> v;
 6 map<string, int> mp;
 7 bool cmp(string a, string b) {
 8     return mp[a] < mp[b];
 9 }
10 
11 int main() {
12     freopen("tourist.txt", "r", stdin);
13     freopen("tourist_out.txt", "w", stdout);
14     int T;
15     scanf("%d", &T);
16     for(int kase = 1; kase <= T; ++kase) {
17         LL K, N, V;
18         scanf("%lld %lld %lld", &N, &K, &V);
19         v.clear();
20         mp.clear();
21         for(int i = 0; i < N; ++i) cin >> str[i], mp[str[i]] = i;
22         int st = (K * (V - 1) - 1) % N;
23         printf("Case #%d:", kase);
24         for(int i = 1; i <= K; ++i) st = (st + 1) % N, v.push_back(str[st]);
25         sort(v.begin(), v.end(), cmp);
26         for(int i = 0; i < v.size(); ++i) printf(" %s", v[i].c_str());
27         puts("");
28     }
29     return 0;
30 }
Aguin

相关文章:

  • 2022-12-23
  • 2021-06-29
  • 2022-01-01
  • 2021-09-18
  • 2021-10-03
  • 2022-03-04
  • 2022-12-23
  • 2021-06-06
猜你喜欢
  • 2021-12-17
  • 2022-02-03
  • 2022-12-23
  • 2021-06-24
  • 2022-01-21
  • 2021-10-01
  • 2021-08-06
相关资源
相似解决方案