Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the name of Allah.
- // We're nothing and you're everything.
- // Ya Ali!
- /*
- , \ / ,
- / \ )\__/( / \
- / \ (_\ /_) / \
- ____/_____\__\@ @/___/_____\____
- | |\../| |
- | \VV/ |
- | ------___------- |
- |__________Chuta Dragon___________|
- | /\ / \\ \ /\ |
- | / V )) V \ |
- |/ ` // ' \|
- ` V '
- */
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<ll,ll>pll;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
- #define fi first
- #define se second
- #define pb push_back
- ll const MOD=1000000007;
- ///-------------------------------------------------------------------------------------------------///
- /// KARMA IS LIKE 69,,, YOU GET WHAT YOU GIVE ///
- ///-------------------------------------------------------------------------------------------------///
- void input(ll ara[],ll n)
- {
- for(ll i=0; i<n; i++)
- cin>>ara[i];
- }
- void output(ll ara[],ll n)
- {
- for(ll i=0; i<n; i++)
- cout<<ara[i]<<" ";
- }
- ll mx1(ll ara[],ll n)
- {
- ll mx=-1;
- for(ll i=0; i<n; i++)
- if(ara[i]>mx)
- mx=ara[i];
- return mx;
- }
- ll mn1(ll ara[],ll n)
- {
- ll mn=1e18;
- for(ll i=1; i<=n; i++)
- if(ara[i]<mn)
- mn=ara[i];
- return mn;
- }
- #define eb emplace_back
- int main()
- {
- fastread();
- ll t;
- ll kase=1;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- vector<pair<ll,pair<ll,ll>>>v;
- for(ll i=0;i<n;i++)
- {
- ll a,b;
- cin>>a>>b;
- v.push_back({a,{b,i}});
- }
- sort(v.begin(),v.end());
- for(ll i=0;i<n;i++)
- {
- cout<<v[i].first<<" ";
- cout<<v[i].second.first<<" ";
- cout<<v[i].second.second<<endl;
- }
- ll j=0,c=0;
- bool f=true;
- char ara[n+1];
- for(ll i=0;i<n;i++)
- {
- if(v[i].first>=j )
- {
- ara[v[i].second.second]='J';
- j=v[i].second.first;
- }else if(v[i].first>=c )
- {
- ara[v[i].second.second]='C';
- c=v[i].second.first;
- }else
- {
- f=false ;
- break;
- }
- }
- cout<<"Case #<<"<<kase++<<": ";
- if(f)
- {
- for(ll i=0;i<n;i++)
- {
- cout<<ara[i];
- }
- cout<<endl;
- }
- else cout<<"IMPOSSIBLE"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement