제출 #1038528

#제출 시각아이디문제언어결과실행 시간메모리
1038528pera돌 무게 재기 (IZhO11_stones)C++17
0 / 100
1 ms600 KiB
#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 timeMemoryGrader output
Fetching results...