The first official participation in the codechef competition. It is a CF-like website in India, but I saw its comments earlier than CF (CF seems to have been established in 10 years)
This website seems to have this XX cook off every month, and the question is not as easy as CF (this is from hard to easy... I don't know how it was)
Okay, let's start with the question. At first, I habitually read question a and thought about it for 10 minutes (I thought it was the CF model). Let's refresh it, the last question was found to be the best in the audience! Please refer to the following link for more information! If you do not need any advanced algorithms, you just need to use them to obtain the number of occurrences of 26 letters in each line. Then, you can scan n rows to find n rows of Public letters (note that they can be repeated, for example, "HPP", 1wa at first ).
#include <map>#include <set>#include <list>#include <queue>#include <deque>#include <stack>#include <string>#include <time.h>#include <cstdio>#include <math.h>#include <iomanip>#include <cstdlib>#include <limits.h>#include <string.h>#include <iostream>#include <fstream>#include <algorithm>using namespace std; #define LL long long#define MIN INT_MIN#define MAX INT_MAX#define PI acos(-1.0)#define FRE freopen ("input.txt","r",stdin)#define FF freopen ("output.txt","w",stdout)#define eps 1e-8#define N 50005char str[110];int cnt[110][30];bool vis[30];int ans[30];void gao(int k,int id){ int i; for (i = 0 ; i < k ; i++)printf("%c",id+'a');}int main(){ int n; while(scanf("%d",&n) != -1 ){ int i,j; memset(cnt,0,sizeof(cnt)); for (i = 0 ; i < n ;i++ ){ scanf("%s",str); for (j = 0; j < strlen(str); j++) { int id = str[j] - 'a'; vis[id] = 1; cnt[i][id]++; } } int k = 0; bool ok = 0; for (i = 0 ; i < 26; i++){ int minm = MAX; for (j = 0; j < n; j++) { if (cnt[j][i] == 0) { break; } else minm = min(cnt[j][i],minm); } if (j >= n) { gao(minm,i); ok = 1; } } if (!ok) printf("no such string"); puts(""); } return 0;}