Submission #800818

# Submission time Handle Problem Language Result Execution time Memory
800818 2023-08-01T21:59:52 Z Liudas Horses (IOI15_horses) C++17
0 / 100
155 ms 41856 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
class segtree{
public:
    struct nodes{
        double logx, logy;
        long long X, Y;
    };
    vector<int> X, Y;
    vector<nodes> tree;
    int N;
    long long MOD = 1e9 + 7;
    nodes comp(nodes a, nodes b){
        nodes c = a;
        if(a.logy < b.logx + b.logy){
            c.logx += b.logx;
            c.logy = b.logy;
            c.X = c.X * b.X % MOD;
            c.Y = b.Y;
        }
        return c;
    }
    void init(int NN){
        X.resize(NN);
        Y.resize(NN);
        int K = 1;
        while(K <= NN) K *= 2;
        N = K;
        tree.assign(K * 2, {0, 0, 0, 0});
    }
    void add(int node, int l, int r, int pos){
        if(pos < l || pos > r){
            return;
        }
        if(r - l == 1){
            tree[node].X = X[pos];
            tree[node].logx = log((double)X[pos]);
            tree[node].logy = log((double)Y[pos]);
            tree[node].Y = Y[pos];
            return;
        }
        int mid = (l + r) / 2;
        if(pos < mid){
            add(node * 2 + 1, l, mid, pos);
        }
        else{
            add(node * 2 + 2, mid, r, pos);
        }
        tree[node] = comp(tree[node * 2 + 1], tree[node * 2 + 2]);
    }
    void add(int pos){
        add(0, 0, N, pos);
    }
    long long ans(){
        return tree[0].X * tree[0].Y % MOD;
    }
};
segtree tree;
int init(int NN, int XX[], int YY[]){
    int N = NN;
    tree.init(N);
    for(int i = 0; i < N; i ++){
        tree.X[i] = XX[i];
        tree.Y[i] = YY[i];
        tree.add(i);
    }
    return tree.ans();
}
int updateX(int pos, int val){
    tree.X[pos] = val;
    tree.add(pos);
    return tree.ans();
}
int updateY(int pos, int val){
    tree.Y[pos] = val;
    tree.add(pos);
    return tree.ans();
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:68:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   68 |     return tree.ans();
      |            ~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:73:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   73 |     return tree.ans();
      |            ~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:78:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   78 |     return tree.ans();
      |            ~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 41856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -