Hiring Test Problem Code: HIRETESTSubmit
A company conducted a coding test to hire candidates. candidates appeared for the test, and each of them faced problems. Each problem was either unsolved by a candidate (denoted by 'U'), solved partially (denoted by 'P'), or solved completely (denoted by 'F').
To pass the test, each candidate needs to either solve or more problems completely, or solve problems completely, and or more problems partially.
Given the above specifications as input, print a line containing integers. The integer should be if the candidate has passed the test, else it should be .
Input:
- The first line of the input contains an integer , denoting the number of test cases.
- The first line of each test case contains two space-separated integers, and , denoting the number of candidates who appeared for the test, and the number of problems in the test, respectively.
- The second line of each test case contains two space-separated integers, and , as described above, respectively.
- The next lines contain characters each. The character of the line denotes the result of the candidate in the problem. 'F' denotes that the problem was solved completely, 'P' denotes partial solve, and 'U' denotes that the problem was not solved by the candidate.
Output:
For each test case, print a single line containing integers. The integer denotes the result of the candidate. denotes that the candidate passed the test, while denotes that he/she failed the test.
Constraints
Sample Input 1
3
4 5
3 2
FUFFP
PFPFU
UPFFU
PPPFP
3 4
1 3
PUPP
UUUU
UFUU
1 3
2 2
PPP
Sample Output 1
1100
101
0
Explanation
Sample Test 1: There are candidates and problems. Each candidate needs to solve or more problems completely, or problems completely and or more problems partially. Only the first and the second candidates satisfy this.
Sample Test 2: The candidates need to either solve at least one problem completely, or they need to solve three or more problems partially. Only candidates and satisfy this.
Sample Test 3: The candidate needs to either solve two or more problems completely, or solve at least one problems completely and two problems partially. The candidate does not satisfy this.
#include<iostream>
#define ll long long
#include<vector>
#include<algorithm>
using namespace std;
void solve() {
string s;
ll n, m;
cin >> n >> m;
ll x, y;
cin >> x >> y;
for (int i = 0; i < n; i++)
{
vector<char> v(m);
for (int i = 0; i < m; i++)
{
cin >> v[i];
}
ll countF = 0, countP = 0;
for (int i = 0; i < m; i++)
{
if (v[i] == 'P')
countP++;
if (v[i] == 'F')
countF++;
}
if (countF >= x)
s += "1";
else if (countF == x - 1 && countP >= y)
s += "1";
else
s += "0";
}
cout << s << "\n";
}
int main()
{
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
No comments:
Post a Comment