Submission #746028

# Submission time Handle Problem Language Result Execution time Memory
746028 2023-05-21T10:40:05 Z Boomyday Horses (IOI15_horses) C++17
17 / 100
36 ms 20848 KB
//
// Created by adavy on 2/11/2023.
//
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using ii = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTU tcT, class U

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;

// pairs
#define mp make_pair
#define f first
#define s second

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front

const int MOD = 1e9+9; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!


#include <stdio.h>
#include <assert.h>

struct Modular {
    int value;
    static const int MOD_value = MOD;

    Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
    Modular(long long a, long long b) : value(0){ *this += a; *this /= b;}

    Modular& operator+=(Modular const& b) {value += b.value; if (value >= MOD) value -= MOD; return *this;}
    Modular& operator-=(Modular const& b) {value -= b.value; if (value < 0) value += MOD;return *this;}
    Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}

    friend Modular mexp(Modular a, long long e) {
        Modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }

    Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
    friend Modular operator+(Modular a, Modular const b) { return a += b; }
    friend Modular operator-(Modular a, Modular const b) { return a -= b; }
    friend Modular operator-(Modular const a) { return 0 - a; }
    friend Modular operator*(Modular a, Modular const b) { return a *= b; }
    friend Modular operator/(Modular a, Modular const b) { return a /= b; }
    friend std::ostream& operator<<(std::ostream& os, Modular const& a) {return os << a.value;}
    friend bool operator==(Modular const& a, Modular const& b) {return a.value == b.value;}
    friend bool operator!=(Modular const& a, Modular const& b) {return a.value != b.value;}
};


vl X, Y;
ll sz;
vl seg;
set<int> brks;

void update(int i, ll x){
    i += sz;
    seg[i] = x;
    x >>= 1;
    while (x > 0){
        seg[x] = max(seg[1<<x], seg[(1<<x)|1]);
        x >>= 1;
    }
}

ll query(int l, int r){
    l += sz; r += sz;
    ll ans = 0;
    while(l<=r){
        if (l&1) ans = max(ans, seg[l++]);
        if (!(r&1)) ans = max(ans, seg[r--]);
        l>>=1;
        r>>=1;

    }
    return ans;
}

ll solve(){
    return 0;
}

int init(int N, int Xi[], int Yi[]) {
    sz = 1<<(ll)(log2(N)+1);
    seg.rsz(2*sz);
    fill(all(seg),0);

    ll myHorses = 1;
    ll bestScr = 0;
    brks.insert(N);
    X = vl(Xi, Xi+N);
    Y = vl(Yi, Yi+N);
    F0R(i, N){
        //update(i, Y[i]);
        //if (X[i] > 1) brks.insert(i);

    }
    F0R(i, N){
        myHorses *= X[i];
        bestScr = max(bestScr, myHorses*Y[i]);
    }
    return bestScr%MOD;
}

int updateX(int pos, int val) {
    return 0;
}

int updateY(int pos, int val) {
    return 0;
}
/*

int main(){
    int n; cin >> n;
    int x[n], y[n];
    F0R(i, n) cin >> x[i];
    F0R(i, n) cin >> y[i];
    cout << init(n, x, y) << endl;

}
*/

Compilation message

horses.cpp: In constructor 'Modular::Modular(long long int)':
horses.cpp:71:42: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   71 |     Modular(long long v = 0) { value = v % MOD; if (value < 0) value += MOD;}
      |                                        ~~^~~~~
horses.cpp: In member function 'Modular& Modular::operator*=(const Modular&)':
horses.cpp:76:79: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   76 |     Modular& operator*=(Modular const& b) {value = (long long)value * b.value % MOD;return *this;}
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'void update(int, ll)':
horses.cpp:102:7: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  102 |     i += sz;
      |     ~~^~~~~
horses.cpp: In function 'll query(int, int)':
horses.cpp:112:7: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  112 |     l += sz; r += sz;
      |     ~~^~~~~
horses.cpp:112:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  112 |     l += sz; r += sz;
      |              ~~^~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:147:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  147 |     return bestScr%MOD;
      |            ~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:150:17: warning: unused parameter 'pos' [-Wunused-parameter]
  150 | int updateX(int pos, int val) {
      |             ~~~~^~~
horses.cpp:150:26: warning: unused parameter 'val' [-Wunused-parameter]
  150 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:154:17: warning: unused parameter 'pos' [-Wunused-parameter]
  154 | int updateY(int pos, int val) {
      |             ~~~~^~~
horses.cpp:154:26: warning: unused parameter 'val' [-Wunused-parameter]
  154 | int updateY(int pos, int val) {
      |                      ~~~~^~~
# 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 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 1 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 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 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 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 20848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 272 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Incorrect 1 ms 296 KB Output isn't correct
22 Halted 0 ms 0 KB -