답안 #65054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65054 2018-08-06T13:53:00 Z theknife2001 게임 (IOI13_game) C++17
0 / 100
7 ms 952 KB
#include "game.h"
#include <bits/stdc++.h>
#define mid (l+r)/2


using namespace std;


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;
}

const int N=1e5+55;
long long tree[N*4][20];
int n,m;

void init(int R, int C)
{
    n=R;
    m=C;
}

void up(int l , int r , int node , int ind , long long val , int lev)
{
    if(l==r&&l==ind)
        tree[node][lev]=val;
    if(ind<=mid)
        up(l,mid,node*2,ind,val,lev);
    else
        up(mid+1,r,node*2+1,ind,val,lev);
    tree[node][lev]=gcd2(tree[node*2][lev],tree[node*2+1][lev]);
}

long long query(int l , int r , int node , int x , int y , int lev)
{
    if(x<=l&&r<=y)
        return tree[node][lev];
    long long temp1=-1;
    long long temp2=-1;
    if(mid>=x)
        temp1=query(l,mid,node*2,x,y,lev);
    if(mid<=y)
        temp2=query(mid+1,r,node*2,x,y,lev);
    if(temp1!=-1&&temp2!=-1)
        return gcd2(temp1,temp2);
    if(temp1!=-1)
        return temp1;
    return temp2;

}


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

long long calculate(int P, int Q, int U, int V)
{
    if(P>U)
        swap(P,U);
    if(Q>V)
        swap(Q,V);
    long long ans;
    for(int i=P;i<=Q;i++)
    {
        if(i==P)
            ans=query(0,m-1,1,U,V,i);
        else
            ans=gcd2(ans,query(0,m-1,1,U,V,i));
    }
    return ans;
}

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:78:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ans;
            ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 828 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -