Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 24, 2016 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/d9c0d7a25ca2e24ca17b to your computer and use it in GitHub Desktop.
Save jianminchen/d9c0d7a25ca2e24ca17b to your computer and use it in GitHub Desktop.
Two string - use gets, and array
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <ctime>
using namespace std;
#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
const ld pi = 3.14159265359;
template < typename T > T abs(T x)
{
return x > 0 ? x : -x;
}
const int maxn = 100005;
char s[maxn], t[maxn];
int was[30];
int main()
{
//gen();
//freopen("a.in", "r", stdin);
//srand(time(NULL));
int tt;
scanf("%d\n", &tt);
while (tt--)
{
gets(s);
gets(t);
int n = strlen(s);
for (int i = 0; i < 30; i++)
was[i] = 0;
for (int i = 0; i < n; i++)
was[s[i] - 'a'] = 1;
bool good = false;
n = strlen(t);
for (int i = 0; i < n; i++)
if (was[t[i] - 'a'])
good = true;
if (good)
puts("YES");
else
puts("NO");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment