#include #include #include #include #include #include using namespace std; struct magic { int from, to; int height; int col; magic(int f,int t, int h, int c): from(f), to(t), height(h), col(c){} }; typedef vector vmagic; bool magic_from(const magic &a, const magic &b){ return !(a.from==b.from? a.height>b.height :a.from pqmagic; #define LAST 1000000000 int main(void) { int ncases; cin >> ncases; vmagic mg_vec; pqmagic mg_pq; mg_vec.push_back(magic(0,LAST+3,-1,1)); mg_vec.push_back(magic(LAST,LAST+1,ncases+2,0)); for ( int i= 0 ; i>from>>to>>c; mg_vec.push_back(magic(from,to,i,c=='b'?0:1)); } sort(mg_vec.begin(), mg_vec.end(), magic_from); int record=0; int rec_from, rec_to; int wfrom=0; mg_pq.push(mg_vec.back()); mg_vec.pop_back(); while ( !mg_pq.empty() ) { magic &cur = mg_pq.top(); magic &next = mg_vec.back(); if ( cur.to=0 ) { int test=cur_to-wfrom; if ( test>record ) { record=test; rec_from=wfrom; rec_to=cur_to; } } wfrom=-1; } else{ if ( wfrom<0 ) wfrom=cur_to; } } else { if ( next.height>cur.height ) { if ( next.col==0 ) { //updating by black if( wfrom>=0 ) { int test=next.from-wfrom; if ( test>record ) { record=test; rec_from=wfrom; rec_to=next.from; } } wfrom = -1; } else{ //updating by white if ( wfrom<0 ) wfrom = next.from; } } mg_pq.push(mg_vec.back()); mg_vec.pop_back(); if ( mg_vec.empty() )break; } } cout<