Created
March 25, 2016 00:10
-
-
Save jianminchen/ff3fd27b8c1245322adf to your computer and use it in GitHub Desktop.
Two string - C++ function template std::fill -
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <cstring> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
const int Maxn = 100005; | |
const int Maxl = 26; | |
int t; | |
char s[Maxn]; | |
int slen; | |
bool hasa[Maxl], hasb[Maxl]; | |
int main() { | |
scanf("%d", &t); | |
while (t--) { | |
fill(hasa, hasa + Maxl, false); | |
scanf("%s", s); slen = strlen(s); | |
for (int i = 0; i < slen; i++) | |
hasa[s[i] - 'a'] = true; | |
fill(hasb, hasb + Maxl, false); | |
scanf("%s", s); slen = strlen(s); | |
for (int i = 0; i < slen; i++) | |
hasb[s[i] - 'a'] = true; | |
bool has = false; | |
for (int i = 0; i < Maxl; i++) | |
has = has || hasa[i] && hasb[i]; | |
printf("%s\n", has? "YES": "NO"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment