답안 #965698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965698 2024-04-19T05:36:33 Z Amr 게임 (IOI13_game) C++17
27 / 100
717 ms 44944 KB
#include "game.h"
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll siz = 1;
const int N = 5e5;
ll seg[11][N];
ll r , c;
long long gcd2(long long X, long long Y) {
    long long tmp;
    if(X<Y) swap(X,Y);
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}
void upd(ll ver, ll in , ll val , ll x = 0, ll lx = 0, ll rx = siz)
{
   // cout << lx <<  " " << rx << "   ";
    if(rx-lx==1)
    {
        seg[ver][x] = val;
        return;
    }
    ll mid = (lx+rx)/2;
    if(in<mid)
    upd(ver,in,val,2*x+1,lx,mid);
    else
    upd(ver,in,val,2*x+2,mid,rx);
    seg[ver][x] = gcd2(seg[ver][2*x+1],seg[ver][2*x+2]);
   // cout << seg[ver][] << " ";
}
ll get(ll ver, ll l ,ll r, ll x = 0, ll lx = 0, ll rx = siz)
{
    if(lx>=r||rx<=l) return 0;
    if(lx>=l&&rx<=r) return seg[ver][x];
    ll mid = (lx+rx)/2;
    ll s1 = get(ver,l,r,2*x+1,lx,mid);
    ll s2 = get(ver,l,r,2*x+2,mid,rx);
    return gcd2(s1,s2);
}
void init(int R, int C) {
    r = R , c = C;
    siz = C;
}

void update(int P, int Q, long long K) {
   upd(P,Q,K);
  // cout << seg[P][0] << endl;
}

long long calculate(int P, int Q, int U, int V) {
    ll gcd3 = 0;
    for(int i = P; i <= U; i++)
    {
        //cout << get(i,Q,V+1) <<  endl;
        gcd3= gcd2(gcd3,get(i,Q,V+1));
    }
    return gcd3;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 717 ms 26824 KB Output is correct
5 Correct 489 ms 30864 KB Output is correct
6 Correct 544 ms 25860 KB Output is correct
7 Correct 619 ms 44944 KB Output is correct
8 Correct 474 ms 23908 KB Output is correct
9 Correct 537 ms 27732 KB Output is correct
10 Correct 504 ms 25428 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 3 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -