Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: 曹北健
- Result: WA Submission_id: 4531247
- Created at: Tue Jun 14 2022 19:57:03 GMT+0800 (China Standard Time)
- Problem_id: 4646 Time: 3 Memory: 1652
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <ctype.h>
- #include <string.h>
- #pragma warning(disable:4996)
- typedef long long LL;
- char s1[114514] = { 0 }, s2[114514] = { 0 };
- char data1[128][128] = { 0 };
- char common[128][128] = { 0 };
- int cmparr(const void *p, const void *q){
- return strcmp((char *)p, (char *)q);
- }
- int main(){
- #ifdef _DEBUG
- //fclose(stdin);
- freopen("../../../in.txt", "rb", stdin);
- //freopen("../../../out.txt", "w", stdout);
- #endif // _DEBUG
- char tmp[128] = { 0 }, buf1[128] = { 0 };
- char *end, *p;
- int l, k1 = 0, i, k2 = 0, j, flag = 0;
- fgets(s1, 114514, stdin);
- end = strrchr(s1, '}');
- *end = 0;
- p = strtok(s1 + 1, ",");
- while(p){
- l = 0;
- //strcpy(data1[k1], p);
- for(i = 0; p[i]; i++){
- if(isalpha(p[i])){
- data1[k1][l] = p[i];
- l++;
- }
- }
- p = strtok(0, ",");
- k1++;
- }
- fgets(s2, 114514, stdin);
- end = strrchr(s2, '}');
- *end = 0;
- p = strtok(s2 + 1, ",");
- while(p){
- //strcpy(tmp, p);
- l = 0;
- memset(tmp, 0, 128);
- for(i = 0; p[i]; i++){
- if(isalpha(p[i])){
- tmp[l] = p[i];
- l++;
- }
- }
- for(i = 0; i < k1; i++){
- if(!strcmp(tmp, data1[i])){
- flag = 0;
- for(j = 0; j < k2; j++){
- if(!strcmp(tmp,common[j])){
- flag = 1;
- break;
- }
- }
- if(!flag){
- strcpy(common[k2], tmp);
- k2++;
- }
- break;
- }
- }
- p = strtok(0, ",");
- }
- if(k2){
- qsort(common, k2, 128, cmparr);
- for(i = 0; i < k2; i++){
- printf("%s ", common[i]);
- }
- }
- else{
- puts("NONE");
- }
- #ifdef _DEBUG
- freopen("CON", "rb", stdin);
- //freopen("CON", "w", stdout);
- system("pause");
- #endif // _DEBUG
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement