-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParentingPartneringReturns.cpp
More file actions
50 lines (47 loc) · 1.26 KB
/
ParentingPartneringReturns.cpp
File metadata and controls
50 lines (47 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
void printCases(int count, string result){
cout << "Case #" << count << ":" << " " << result << endl;
}
string setActivities(vector<tuple<int, int, int>> list){
sort(list.begin(), list.end());
char order[list.size()];
int CameronEndingTime = -1, JamieEndingTime = -1 , s,e, index;
for(int i = 0; i < list.size(); i++){
tie(s,e,index) = list[i];
if(s >= CameronEndingTime){
CameronEndingTime = e;
order[index] = 'C';
}
else if(s >= JamieEndingTime){
JamieEndingTime = e;
order[index] = 'J';
}
else break;
}
order[list.size()] = '\0';
string str(order);
return str.length() == list.size() ? str : "IMPOSSIBLE";
}
void testcases(){
int test, count = 0;
cin >> test;
while(count != test){
int activities, start, end;
cin >> activities;
vector<tuple<int, int, int>> list;
for(int i = 0 ; i < activities; i++){
cin >> start >> end;
list.push_back({start, end, i});
}
count++;
printCases(count, setActivities(list));
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
testcases();
return 0;
}