// начал в 19:52
// 20:22 - прервался до этого времени (smplayer reisntall) и начал снова
#include <bits/stdc++.h>
using namespace std;
const int n0=1e5+123;
int n,l[n0],r[n0];
set<int> unmatchedL[2],unmatchedR[2];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n;
for(int i=1; i<=n; i++) {
int x,y;cin >> x >> y;
unmatchedL[y-1].insert(x);
unmatchedR[y-1].insert(x);
// greedy matching for 0 < 1
// unmatchedL[0] < unmatchedL[1]
while(!unmatchedL[0].empty()) {
auto it=unmatchedL[0].begin();
auto it2=unmatchedL[1].upper_bound(*it);
if(it2!=unmatchedL[1].end()) {
unmatchedL[1].erase(it2);
unmatchedL[0].erase(it);
} else {
break;
}
}
if(unmatchedL[0].empty() || unmatchedL[1].empty()) {
cout << "<\n";
} else {
// greedy matching for 0 > 1
while(!unmatchedR[1].empty()) {
auto it=unmatchedR[1].begin();
auto it2=unmatchedR[0].upper_bound(*it);
if(it2!=unmatchedR[0].end()) {
unmatchedR[0].erase(it2);
unmatchedR[1].erase(it);
} else {
break;
}
}
if(unmatchedR[0].empty() || unmatchedR[1].empty()) {
cout << ">\n";
} else {
cout << "?\n";
}
// else ?
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |