| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 593961 | hyakup | Simple game (IZhO17_game) | C++17 | 64 ms | 6796 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, maxh = 1000010; 
int height[maxn], bit[maxh];
int n, q; 
void update( int i, int v ){
    
    for( int j = i; j < maxh; j += j&-j) bit[j] += v;
    
}
int query( int i){
    
    int soma = 0;
    
    for( int j = i; j > 0; j -= j&-j) soma += bit[j];
    
    return soma;
}
int main(){
    
    scanf("%d %d", &n, &q);
    
    for( int i = 0; i < maxh; i++) bit[i] = 0;
    
    for( int i = 1; i <= n; i++) scanf("%d",  &height[i]);
    
    for( int i = 1; i < n; i++){
        
        update( min(height[i], height[i + 1]), 1 );
        update( max(height[i], height[i + 1]) + 1, -1 );
        
    }
    
    for( int i = 0; i < q; i++){
        
        int type; scanf("%d", &type);
        
        if( type == 1 ){
            
            int pos, val; scanf("%d %d", &pos, &val);
            
            if( pos < n ){
                
                update( min(height[pos], height[pos + 1]), -1 );
                update( max(height[pos], height[pos + 1]) + 1, 1 );
                
                update( min(val, height[pos + 1]), 1 );
                update( max(val, height[pos + 1]) + 1, -1 );
                
            }
            
            if( pos > 1 ){
                
                update( min(height[pos], height[pos - 1]), -1 );
                update( max(height[pos], height[pos - 1]) + 1, 1 );
                
                update( min(val, height[pos - 1]), 1 );
                update( max(val, height[pos - 1]) + 1, -1 );
        
            }
            
            height[pos] = val;
        }
        
        if( type == 2 ){
            int h; scanf("%d", &h);
            
            printf("%d\n", query(h));
            
        }
    }
    
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
