# FOOLFORM Editorial

**URL:** <https://discuss.codechef.com/t/foolform-editorial/100258>\
**Category:** editorial\
**Tags:** recursion, strings\
**Created:** [March 28, 2022, 8:27pm UTC](https://discuss.codechef.com/t/foolform-editorial/100258 "2022-03-28T20:27:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keyurchd\_11](https://discuss.codechef.com/user_avatar/discuss.codechef.com/keyurchd_11/32/117442_2.png) [@keyurchd\_11](https://discuss.codechef.com/u/keyurchd_11)\
**Post date:** [March 28, 2022, 8:27pm UTC](https://discuss.codechef.com/t/foolform-editorial/100258/1 "2022-03-28T20:27:25Z")

</div>

# Problem Link:

[Fool’s Programming Contest](https://www.codechef.com/FOOL2022)  
[Foolish formation](https://www.codechef.com/FOOL2022/problems/FOOLFORM)

_ **Author:** _ [Amul Agarwal](https://www.codechef.com/users/awesome_amul)  
_ **Testers:** _ [Ishaan Shah](https://www.codechef.com/users/ishaanshah), [Sanyam Shah](https://www.codechef.com/users/mash_28), [Sambasai Andem](https://www.codechef.com/users/sambasai) and [Tejas Chaudhari](https://www.codechef.com/users/kryptai)  
_ **Editorialist:** _ [Keyur Chaudhari](https://www.codechef.com/users/keyurchd_11)

# DIFFICULTY:

SIMPLE/MEDIUM

# EXPLANATION:

The problem statement had a link to the same page as the problem. This hint was supposed to indicate recursion. This problem was based on the concept of "[Recursive acronym](https://en.wikipedia.org/wiki/Recursive_acronym)".  
A Recursive acronym is an acronym that refers to itself.

Examples:  
[PIP](https://en.wikipedia.org/wiki/Pip_(Python)) — PIP Installs Packages  
GNU— GNU’s Not Unix

In this problem, we had to check if the sequence of strings given forms a pattern similar to a recursive acronym. The solution was to print “YES” if the string formed by the first characters of all given strings was also present in the list of strings given, and “NO” otherwise.

Another **hint** given in the problem: The problem code was “_ **FOOL** _FORM” which could have hinted at “_ **FULL** _ FORM”

> **Sample Explanation**
>
> ### Sample Input:
> 
> > 1  
> > 5  
> > eve visited every royal yacht
> 
> ### Sample Output:
> 
> > YES
> 
> ### Explanation:
> 
> > String formed from first characters = “every”  
> > Since “every” is present in the input, the answer is “YES”

  

> **Tester's Solution**
>
> ```cpp
> #include <bits/stdc++.h>
> using namespace std;
> #define int long long
> #define pb push_back
> #define fast \
> ios_base::sync_with_stdio(0); \
> cin.tie(0); \
> cout.tie(0)
> #define tc \
> int t; \
> cin >> t; \
> while (t--)
> 
> signed main()
> {
> fast;
> tc
> {
> int n;
> cin >> n;
> string a[n];
> string trgt;
> for (int i = 0; i < n; i++) {
> cin >> a[i];
> trgt.pb(a[i][0]);
> }
> int f = 0;
> for (int i = 0; i < n; i++) {
> if (a[i] == trgt) {
> f = 1;
> break;
> }
> }
> if (f) {
> cout << "YES" << endl;
> }
> else {
> cout << "NO" << endl;
> }
> }
> }
> 
> ```

  

> **Editorialist's Solution**
>
> ```cpp
> #include <bits/stdc++.h>
> 
> #include <iostream>
> using namespace std;
> 
> int main()
> {
> ios_base::sync_with_stdio(false);
> cin.tie(NULL);
> int t;
> cin >> t;
> while (t--) {
> int n;
> cin >> n;
> vector<string> v(n);
> string req = "";
> for (int i = 0; i < n; i++) {
> cin >> v[i];
> req += v[i][0];
> }
> bool okay = false;
> for (auto s1 : v) {
> if (s1.size() != req.size()) continue;
> if (req == s1) {
> okay = true;
> break;
> }
> }
> if (okay)
> cout << "YES" << endl;
> else
> cout << "NO" << endl;
> }
> return 0;
> }
> 
> ```
