Created
March 25, 2016 00:21
-
-
Save jianminchen/765ba74888057b887cac to your computer and use it in GitHub Desktop.
Two string - C++ thinking in bitset, size_t, strong C++ knowledge
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 <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