# Daily Coding Challenge #73

This is a series of Daily Coding Challenge. Each day I show a few solutions written in C++. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

/*
Codeforces Round #658 (Div. 2) - A. Common Subsequence
https://codeforces.com/contest/1382/problem/A
*/

#include <bits/stdc++.h>
using namespace std;
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

bool solve(){
// find the first common element k and return
// YES
// 1 k
// else return NO
int a,b;
cin >> a >> b;
vector<int> aa(a);
vector<int> bb(b);
for(int i=0;i<a;i++) cin >> aa[i];
for(int i=0;i<b;i++) cin >> bb[i];
for(int i=0;i<b;i++){
if(find(aa.begin(), aa.end(), bb[i])!=aa.end()){
cout << "YES\n";
cout << 1 << " " << bb[i] << "\n";
return true;
}
}
cout << "NO\n";
return false;
}

int main()
{
FAST_INP;
int n,t;
cin >> t;
while(t--){
solve();
}
return 0;
}



/*
Codeforces Round #658 (Div. 2) - Sequential Nim
https://codeforces.com/contest/1382/problem/B
*/

#include <bits/stdc++.h>
using namespace std;
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
FAST_INP;
int n,t;
cin >> t;
while(t--){
cin >> n;
vector<int> p(n);
for(int i=0;i<n;i++) cin >> p[i];
int k=0;
// whoever gets the first pile with more than one stone wins
while(k<n&&p[k]==1) k++;
// if all piles have 1 stone, the first player wins when k is odd
cout << ((k==n)^(k%2)?"Second":"First") << "\n";
}
return 0;
}



The source code is available in corresponding repo below. Star and watch for timely updates!

## wingkwong / atcoder

Posted on by:

### Wing-Kam

Consultant by day. Developer by night. AWS certified. Exploring #CloudNative currently.