Submission #1082448

# Submission time Handle Problem Language Result Execution time Memory
1082448 2024-08-31T11:09:09 Z mindiyak Game (IOI13_game) C++14
0 / 100
27 ms 63068 KB
#include "game.h"
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

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

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<2001;i++)for(int j=0;j<10001;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;
}

Compilation message

game.cpp: In function 'void init(int, int)':
game.cpp:24:63: warning: iteration 15 invokes undefined behavior [-Waggressive-loop-optimizations]
   24 |     for(int i=0;i<2001;i++)for(int j=0;j<10001;j++)grid[i][j] = 0;
      |                                                    ~~~~~~~~~~~^~~
game.cpp:24:18: note: within this loop
   24 |     for(int i=0;i<2001;i++)for(int j=0;j<10001;j++)grid[i][j] = 0;
      |                 ~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 63064 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 63068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 63064 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 63068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 63068 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -