답안 #472884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472884 2021-09-14T12:41:28 Z MamdouhN Deda (COCI17_deda) C++14
60 / 140
1000 ms 2944 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

int n,q;
int seg[600005];
int uwu = 927168292;

void update(int idx,int st,int en,int i,int value)
{
    if(en<i||st>i)return;
    if(st==en)
    {
        seg[idx] = value;
        return;
    }
    int mid = (st+en)/2;
    update(idx*2,st,mid,i,value);
    update(idx*2+1,mid+1,en,i,value);
    seg[idx]=min(seg[idx*2],seg[idx*2+1]);
}

int query(int idx,int st,int en,int qs,int y)
{
    if(en<qs||st>n)return uwu;
    if(seg[idx]>y)return uwu;
    if(st==en)return (seg[idx]==0?uwu:st);
    int mid = (st+en)/2;
    int left  = query(idx*2,st,mid,qs,y);
    int right = query(idx*2+1,mid+1,en,qs,y);
    return min(left,right);
}

main()
{
    cin>>n>>q;
    while(q--)
    {
        char c;
        int a,b;
        cin>>c>>a>>b;
        if(c=='M')
        {
            update(1,0,n,b,a);
        }
        else
        {
            int ans = query(1,0,n,b,a);
            cout<<(ans==uwu ? -1:ans)<<endl;
        }
    }
}

Compilation message

deda.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 27 ms 204 KB Output is correct
4 Execution timed out 1092 ms 332 KB Time limit exceeded
5 Execution timed out 1091 ms 2448 KB Time limit exceeded
6 Execution timed out 1081 ms 2944 KB Time limit exceeded
7 Execution timed out 1095 ms 2636 KB Time limit exceeded