답안 #1022175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022175 2024-07-13T10:45:41 Z amine_aroua 웜뱃 (IOI13_wombats) C++17
0 / 100
5 ms 8796 KB
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
struct segTree
{
    int BASE;
    vector<int> tree;
    void build(int n)
    {
        BASE = n;
        while(__builtin_popcount(BASE) != 1)
            BASE++;
        tree.assign(2*BASE , 0);
    }
    void upd(int i , int x)
    {
        tree[i + BASE] = x;
        for(int j = (i + BASE)/2 ; j >= 1 ; j/=2)
        {
            tree[j] = tree[2*j] + tree[2*j + 1];
        }
    }
    int query(int l , int r)
    {
        l+=BASE;
        r+=BASE;
        if(l == r)
            return tree[l];
        int lt = 0 , rt = 0;
        while(l + 1 < r)
        {
            if(l %2 == 0)
            {
                lt = lt + tree[l + 1];
            }
            if(r%2 == 1)
            {
                rt = tree[r - 1] + rt;
            }
            l>>=1;
            r>>=1;
        }
        return lt + rt;
    }
};
vector<vector<int>> h , v;
segTree tree[2];
int r , c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r = R;
    c = C;
    h.assign(R , vector<int>(C));
    v = h;
    for(int i = 0 ; i < R ; i++)
    {
        for(int j = 0;  j < C - 1 ; j++)
        {
            h[i][j] = H[i][j];
        }
    }
    for(int i = 0 ; i < R-1 ; i++)
    {
        for(int j = 0;  j < C ; j++)
        {
            v[i][j] = V[i][j];
        }
    }
    for(int j = 0 ; j < 2 ; j++)
    {
        tree[j].build(R - 1);
        for(int i = 0 ; i < R - 1 ; i++)
        {
            tree[j].upd(i , V[i][j]);
        }
    }
}

void changeH(int P, int Q, int W) {
    h[P][Q] = W;
}

void changeV(int P, int Q, int W) {
    tree[Q].upd(P , W);
}

int escape(int V1, int V2) {
    if(V1 == V2)
    {
        return min(tree[V1].query(0 , r - 1) , tree[1 - V1].query(0 , r - 1) + h[0][0] + h[r-1][0]);
    }
    else
    {
        return min(tree[V1].query(0 , r - 1) + h[r - 1][0] , tree[V2].query(0 , r - 1) + h[0][0]);
    }
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Incorrect 2 ms 5208 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 4956 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 8796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 4956 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 4952 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -