Can anyone advise what's wrong with the below code ?
#include <bits/stdc++.h>
using namespace std;
char check(vector < int > interval, std::map < char, vector < int > > map) {
vector < int > person1 = map['C'];
vector < int > person2 = map['J'];
if (person1[1] <= interval[0] || interval[1] <= person1[0])
return 'C';
if (person2[1] <= interval[0] || interval[1] <= person2[0])
return 'J';
return '\0';
}
int main() {
int T, k = 1;
cin >> T;
while (T--) {
int S, E;
int N;
std::string output = "CJ";
std::map < char, vector < int > > personMap;
bool impossible = false;
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> S >> E;
vector < int > interval;
interval.push_back(S);
interval.push_back(E);
if (i == 1)
personMap['C'] = interval;
if (i == 2)
personMap['J'] = interval;
if (i >= 3) {
char person = check(interval, personMap);
if (person == '\0') {
impossible = true;
} else {
personMap[person] = interval;
output += person;
}
}
}
if (impossible)
output = "IMPOSSIBLE";
cout << "Case #" << k << ": " << output << endl;
//k is for printing the Case Number
k++;
}
return 0;
}
On Tuesday, 7 April 2020 10:52:28 UTC+10, mbauschke wrote:
>
> Hi there,
>
>
>
> I’m trying to submit my solution for Problem 3: „Parenting Partnering
> Returns“ but it’s getting me always a runtime exception. This is strange
> because my Test attempts are always successful. Has anyone ever had a
> problem like this before and knows what it could be?
>
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/1516c4d5-9bd7-4257-9925-7c1af1724e87%40googlegroups.com.