// 32351ZN #include #include #include #include #include #include #include #include #include using namespace std; typedef list ilist_t; #define FOR_EACH(p,q,r) for(p=q;p!=r;p++) #define FOR_EACH_C(p,c) for(p=(c).begin();p!=(c).end();p++) const int INF=1000000000; const int WHITE=1,BLACK=0; int GetColor(int n) { return n == 1 ? WHITE : BLACK; } int main() { int n,a,b; char c; ilist_t table; ilist_t::iterator p; cin >> n; table.push_back(0); table.push_back(INF); while(n--) { cin >> a >> b >> c; int color=BLACK; if(a > b)swap(a,b); if(c == 'w')c = WHITE; else c = BLACK; for(p = table.begin() ; p != table.end() ; p++) { if(*p >= a)break; color ^= 1; } if(color != c) { table.insert(p,a); } while(p != table.end()) { if(*p> b)break; p = table.erase(p); color ^= 1; } if(color != c) { table.insert(p,b); } // FOR_EACH_C(p,table){ // cout << *p << ' '; // } // cout << endl; } int color=BLACK; int prev=0,ans=0,astart,aend; FOR_EACH_C(p,table){ if(color == WHITE){ if(ans < *p - prev) { ans = *p-prev; astart = prev; aend = *p; } } color ^= 1; prev = *p; } cout << astart << ' ' << aend << endl; return 0; }