Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created March 25, 2016 00:21
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/765ba74888057b887cac to your computer and use it in GitHub Desktop.
Save jianminchen/765ba74888057b887cac to your computer and use it in GitHub Desktop.
Two string - C++ thinking in bitset, size_t, strong C++ knowledge
#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <ctime>
#include <cassert>
#include <utility>
using namespace std;
int T;
string A, B;
bitset<26> ba;
int main() {
// freopen("date.in", "r", stdin);
// freopen("date.out","w", stdout);
cin.sync_with_stdio(false);
cin >> T;
while (T--) {
cin >> A >> B;
ba = 0;
for (size_t i = 0; i < A.size(); i++) {
ba[A[i] - 'a'] = 1;
}
bool ok = false;
for (size_t i = 0; i < B.size() && !ok; i++) {
if (ba[B[i] - 'a'] == 1) {
ok = true;
}
}
if (ok) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment