#include #include #include #include using namespace std; #define BEGIN 0 #define END 1 #define WHITE 0 #define BLACK 1 class Event { public: int kind; int position, recolorIndex; Event() {} Event( int kind, int position, int recolorIndex ) : kind(kind), position(position), recolorIndex(recolorIndex) {} bool operator < ( const Event &e ) const { if ( position > e.position ) return true; if ( position < e.position ) return false; return (kind > e.kind); } }; class Recolor { public: int importance; int recolorIndex; Recolor( int importance, int recolorIndex) : importance(importance), recolorIndex(recolorIndex) {} bool operator < ( const Recolor &r ) const { return (importance > r.importance); } }; class Paint { public: int begin, end, color; }; int npaint; vector P; int compute() { priority_queue E; for ( int i = 0; i < P.size(); i++ ) { E.push(Event(BEGIN, P[i].begin, i)); E.push(Event(END , P[i].end , i)); } set S; vector::iterator> IT(P.size()); int maxLength = 0; int prevPosition = 0; int currColor = WHITE; int X, Y; while ( !E.empty() ) { const int position = E.top().position; while ( !E.empty() && E.top().position == position ) { const Event e = E.top(); E.pop(); if ( e.kind == BEGIN ) IT[e.recolorIndex] = S.insert(Recolor(e.recolorIndex, e.recolorIndex)).first; else S.erase(IT[e.recolorIndex]); } if ( position - prevPosition > maxLength && currColor == WHITE ) maxLength = position - prevPosition, X = prevPosition, Y = position; if ( S.empty() ) break; const int color = P[S.begin()->recolorIndex].color; if ( color != currColor ) currColor = color, prevPosition = position; } cout << X << " " << Y << endl; } int main() { cin >> npaint; npaint++; char color; P.resize(npaint); P[0].begin = 0; P[0].end = 1000000000; P[0].color = WHITE; for ( int i = 1; i < npaint; i++ ) { cin >> P[i].begin >> P[i].end >> color; P[i].color = (color == 'b')? BLACK : WHITE; } compute(); return 0; }