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 }