I'm not able to make out why my code below fails. Any help would be most
welcome
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int T;
cin>>T;
for(int tc = 1;tc<=T;tc++){
int N;
cin >> N;
vector<pair<pair<int,int>,int > > vData;
pair<int,int> pC,pJ;
bool bCU = true;
bool bJU = true;
for(int n=0;n<N;n++){
pair<int,int> pii;
cin >> pii.first >> pii.second;
vData.push_back(make_pair(make_pair(pii.second,pii.first),n));
}
sort(vData.begin(),vData.end());
string ans(N,'X');
for(int i=0;i<N;i++){
cout<< vData[i].first.second<< " "<< vData[i].first.first << "
" <<vData[i].second <<endl;
if(bJU){
ans[vData[i].second] = 'J';
pJ = vData[i].first;
bJU = false;
continue;
}
if(vData[i].first.second > pJ.first){
ans[vData[i].second] = 'J';
pJ = vData[i].first;
continue;
}
if(bCU){
ans[vData[i].second] = 'C';
pC = vData[i].first;
bCU = false;
continue;
}
if(vData[i].first.second > pC.first){
ans[vData[i].second] = 'C';
pC = vData[i].first;
continue;
}
ans = "IMPOSSIBLE" ;
}
cout<<"Case #"<<tc<<": "<<ans<<endl;
}
return 0;
}
--
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/21df674a-347e-40b4-bd80-25ed481855d5%40googlegroups.com.