# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1038528 | pera | Weighting stones (IZhO11_stones) | C++17 | 1 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n;
vector<int> col(N) , cnt(2);
set<int> S;
vector<char> u = {'>' , '<' , '?'};
void UPD(int x){
S.insert(x);
auto it = S.lower_bound(x);
if(it != S.begin()){
cnt[col[x]] += (col[x] == col[*prev(it)]);
}
if(S.upper_bound(x) != S.end()){
cnt[col[x]] += (col[x] == col[*next(it)]);
}
if(it != S.begin() && S.upper_bound(x) != S.end()){
cnt[col[*prev(it)]] -= (col[*prev(it)] == col[*next(it)]);
}
}
int main(){
cin >> n;
for(int i = 1;i <= n;i ++){
int r;
cin >> r;
cin >> col[r];
--col[r];
UPD(r);
if(cnt[0] > 0 && cnt[1] > 0){
cout << u[2] << endl;
continue;
}
if(cnt[0] + cnt[1] == 0){
cout << u[col[*--S.end()]] << endl;
continue;
}
int v = 0;
while(cnt[v] == 0){
++v;
}
if(v == col[*--S.end()]){
cout << u[v] << endl;
continue;
}
cout << u[2] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |