답안 #1082449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1082449 2024-08-31T11:10:17 Z mindiyak 게임 (IOI13_game) C++14
27 / 100
605 ms 119572 KB
#include "game.h"
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int r,c;
ll grid[15][500005];

long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}

void init(int R, int C) {
    r = R;c = C;
    for(int i=0;i<15;i++)for(int j=0;j<500005;j++)grid[i][j] = 0;
}

void updater(int i,int pos,int l,int r,int idx,ll k){
    if(l == r){
        grid[i][pos] = k;
        return;
    }   
    int mid = (l+r)/2;
    if(idx<=mid){
        updater(i,2*pos+1,l,mid,idx,k);
    }else{
        updater(i,2*pos+2,mid+1,r,idx,k);
    }
    grid[i][pos] = gcd2(grid[i][2*pos+1],grid[i][2*pos+2]);
}

ll asker(int i,int pos,int l,int r,int ql,int qr){
    if(ql>r || qr<l)return 0;
    if(ql <= l && r <= qr){
        return grid[i][pos];
    }   
    int mid = (l+r)/2;
    return gcd2(asker(i,2*pos+1,l,mid,ql,qr),asker(i,2*pos+2,mid+1,r,ql,qr));
}

void update(int P, int Q, long long K) {
    updater(P,0,0,c-1,Q,K);
}

long long calculate(int P, int Q, int U, int V) {
    ll val = 0;
    for(int i=P;i<=U;i++){
        val = gcd2(val,asker(i,0,0,c-1,Q,V));
    }
    return val;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58968 KB Output is correct
2 Runtime error 71 ms 119456 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58960 KB Output is correct
2 Correct 25 ms 59004 KB Output is correct
3 Correct 26 ms 58972 KB Output is correct
4 Correct 605 ms 63212 KB Output is correct
5 Correct 479 ms 67412 KB Output is correct
6 Correct 515 ms 64692 KB Output is correct
7 Correct 490 ms 64576 KB Output is correct
8 Correct 387 ms 64848 KB Output is correct
9 Correct 516 ms 64548 KB Output is correct
10 Correct 454 ms 64080 KB Output is correct
11 Correct 24 ms 58972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 58940 KB Output is correct
2 Runtime error 72 ms 119484 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58972 KB Output is correct
2 Runtime error 65 ms 119376 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 59056 KB Output is correct
2 Runtime error 86 ms 119572 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -