Facebook Hacker Cup 2018 Qualification Round

Posted aguin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Facebook Hacker Cup 2018 Qualification Round相关的知识,希望对你有一定的参考价值。

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

 

30: Interception

判奇偶

技术分享图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main() {
 5     freopen("interception.txt", "r", stdin);
 6     freopen("interception_out.txt", "w", stdout);
 7     int T;
 8     scanf("%d", &T);
 9     for(int kase = 1; kase <= T; ++kase) {
10         int N, x;
11         scanf("%d", &N);
12         for(int i = N; i >= 0; --i) scanf("%d", &x);
13         if(N & 1) printf("Case #%d: 1
0
", kase);
14         else printf("Case #%d: 0
", kase);
15     }
16     return 0;
17 }
Aguin

 

45: Ethan Searches for a String

找一个和前缀一样的

技术分享图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 char A[2222];
 4 
 5 int main() {
 6     freopen("ethan_searches_for_a_string.txt", "r", stdin);
 7     freopen("ethan_searches_for_a_string_out.txt", "w", stdout);
 8     int T;
 9     scanf("%d", &T);
10     for(int kase = 1; kase <= T; ++kase) {
11         scanf("%s", A + 1);
12         printf("Case #%d: ", kase);
13         int la = strlen(A + 1), flag = 0;
14         for(int i = 2; i <= la; ++i) {
15             if(A[i] != A[1]) continue;
16             int ok = 0;
17             for(int j = i; j <= la; ++j)
18                 if(A[j] != A[j-i+1]) {ok = 1; break;}
19             if(ok) {
20                 for(int j = 1; j < i; ++j) putchar(A[j]);
21                 puts(A + 1);
22                 flag = 1;
23                 break;
24             }
25         }
26         if(!flag) puts("Impossible");
27     }
28     return 0;
29 }
Aguin

 

以上是关于Facebook Hacker Cup 2018 Qualification Round的主要内容,如果未能解决你的问题,请参考以下文章

51NOD 1182 完美字符串

51nod 1182 完美字符串字符串排序+哈希

UCF2018 World Cup Fever

Mail.Ru Cup 2018 Round 1

Mail.Ru Cup 2018 Round 3 Solution

Mail.Ru Cup 2018 Round 2 B. Alice and Hairdresser