Submission #44575

# Submission time Handle Problem Language Result Execution time Memory
44575 2018-04-03T12:06:57 Z yusufake Game (IOI13_game) C++
10 / 100
13000 ms 14876 KB
#include<bits/stdc++.h>
#include "game.h"
using namespace std;

#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
typedef long long ll;

long long gcd(long long X, long long Y) {
    if(X == 0 || Y == 0) {
        return X + Y;
    }
 
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
} 

struct node{
    int p[2];
    ll x;
    node *l, *r;
    node(int a[], ll b) { l=r=NULL; p[0]=a[0]; p[1]=a[1]; x = b; } 
};

node* insert(node *root, int p[], ll x, int k){
    if(root == NULL) return new node(p,x);
    if(p[0] == root->p[0] && p[1] == root->p[1]) { root->x = x; return root; }
    if(p[k] < root->p[k])
        root->l = insert(root->l, p, x, !k);
    else
        root->r = insert(root->r, p, x, !k);
    return root;
}

ll ans;
void qry(node *root, pp p[], int k){
    if(root == NULL) return;
    if(root->p[0] >= p[0].st && root->p[0] <= p[0].nd && root->p[1] >= p[1].st && root->p[1] <= p[1].nd)
        ans = gcd(ans , root->x);
    if(root->p[k] > p[k].st)
        qry(root->l, p, !k);
    if(root->p[k] <= p[k].nd)
        qry(root->r, p, !k);
}

node *root;
ll calculate(int xl, int yl, int xr, int yr){
    ans = 0;
    pp p[2];
    p[0] = mp(xl,xr); p[1] = mp(yl,yr);
    qry(root, p, 0);
    return ans;
}
void update(int x, int y, ll val){
    int p[2]; p[0] = x; p[1] = y;
    root = insert(root, p, val, 0);
}
void init(int a, int b){}

//int main(){}

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;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 2 ms 716 KB Output is correct
6 Correct 3 ms 840 KB Output is correct
7 Correct 2 ms 852 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 2 ms 852 KB Output is correct
12 Correct 2 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 920 KB Output is correct
2 Correct 2 ms 920 KB Output is correct
3 Correct 2 ms 920 KB Output is correct
4 Execution timed out 13073 ms 6520 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6520 KB Output is correct
2 Correct 3 ms 6520 KB Output is correct
3 Correct 2 ms 6520 KB Output is correct
4 Correct 2 ms 6520 KB Output is correct
5 Correct 2 ms 6520 KB Output is correct
6 Correct 2 ms 6520 KB Output is correct
7 Correct 2 ms 6520 KB Output is correct
8 Correct 2 ms 6520 KB Output is correct
9 Correct 2 ms 6520 KB Output is correct
10 Correct 2 ms 6520 KB Output is correct
11 Correct 2 ms 6520 KB Output is correct
12 Execution timed out 13080 ms 9308 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 9308 KB Output is correct
2 Correct 2 ms 9308 KB Output is correct
3 Correct 2 ms 9308 KB Output is correct
4 Correct 2 ms 9308 KB Output is correct
5 Correct 2 ms 9308 KB Output is correct
6 Correct 2 ms 9308 KB Output is correct
7 Correct 2 ms 9308 KB Output is correct
8 Correct 2 ms 9308 KB Output is correct
9 Correct 2 ms 9308 KB Output is correct
10 Correct 2 ms 9308 KB Output is correct
11 Correct 2 ms 9308 KB Output is correct
12 Execution timed out 13099 ms 12068 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12068 KB Output is correct
2 Correct 2 ms 12068 KB Output is correct
3 Correct 2 ms 12068 KB Output is correct
4 Correct 2 ms 12068 KB Output is correct
5 Correct 2 ms 12068 KB Output is correct
6 Correct 2 ms 12068 KB Output is correct
7 Correct 2 ms 12068 KB Output is correct
8 Correct 2 ms 12068 KB Output is correct
9 Correct 2 ms 12068 KB Output is correct
10 Correct 2 ms 12068 KB Output is correct
11 Correct 2 ms 12068 KB Output is correct
12 Execution timed out 13080 ms 14876 KB Time limit exceeded
13 Halted 0 ms 0 KB -