# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1038535 | pera | 돌 무게 재기 (IZhO11_stones) | C++17 | 1 ms | 5464 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n;
vector<int> col(N) , cnt(2);
set<int> S;
vector<string> u = {">" , "<" , "?"};
struct node{
int mn = 0 , mx = 0 , lz = 0;
};
vector<node> t(4 * N);
void push(int u){
t[u * 2].mn += t[u].lz;
t[u * 2 + 1].mn += t[u].lz;
t[u * 2].mx += t[u].lz;
t[u * 2 + 1].mx += t[u].lz;
t[u].lz = 0;
}
void update(int u , int l , int r , int L , int R , int x){
if(l > r || r < L || l > R){
return;
}
if(L <= l && r <= R){
t[u].mn += x;
t[u].mx += x;
t[u].lz += x;
return;
}
push(u);
int m = (l + r) / 2;
update(u * 2 , l , m , L , R , x);
update(u * 2 + 1 , m + 1 , r , L , R , x);
t[u].mn = min(t[u * 2].mn , t[u * 2 + 1].mn);
t[u].mx = max(t[u * 2].mx , t[u * 2 + 1].mx);
}
void UPD(int x){
update(1 , 1 , n , 1 , x , (col[x] == 0 ? 1 : -1));
}
int main(){
cin >> n;
for(int i = 1;i <= n;i ++){
int r;
cin >> r;
cin >> col[r];
--col[r];
UPD(r);
if(t[1].mn >= 0){
cout << u[0] << endl;
continue;
}
if(t[1].mx <= 0){
cout << u[1] << endl;
continue;
}
cout << u[2] << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |