-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcj1.cpp
More file actions
executable file
·62 lines (56 loc) · 1.08 KB
/
cj1.cpp
File metadata and controls
executable file
·62 lines (56 loc) · 1.08 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
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define F first
#define S second
int32_t main(void)
{
int t;
cin>>t;
flp(x, 0, t)
{
int n;
cin>>n;
vector<pair<pair<int, int>, int>> v;
flp(i, 0, n)
{
int x, y;
cin>>x>>y;
v.pb({{x, y}, i});
}
char ans[n];
bool flag=true;
int f1=-1, f2=-1;
sort(v.begin(), v.end());
flp(i, 0, n)
{
if(v[i].F.F>=f1)
{
ans[v[i].S]='C';
f1=v[i].F.S;
}
else if(v[i].F.F>=f2)
{
ans[v[i].S]='J';
f2=v[i].F.S;
}
else
{
flag=false;
break;
}
}
cout<<"Case #"<<x+1<<": ";
if(!flag) cout<<"IMPOSSIBLE\n";
else{
flp(i, 0, n)
cout<<ans[i];
cout<<"\n";
}
}
return 0;
}