Submission #225727

#TimeUsernameProblemLanguageResultExecution timeMemory
225727staniewzkiHorses (IOI15_horses)C++17
17 / 100
138 ms17272 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define ST first #define ND second using PII = pair<int, int>; #include "horses.h" const int mod = int(1e9 + 7); int mul(int a, int b) { return (long long) a * b % mod; } PII operator+(PII a, PII b) { return { max(a.ST, mul(a.ND, b.ST)), mul(a.ND, b.ND) }; } struct Tree { vector<PII> tree; int sz = 1; Tree(int n = 0) { while(sz < n) sz *= 2; tree.resize(sz * 2); } void update(int pos) { pos += sz; while(pos /= 2) tree[pos] = tree[pos * 2] + tree[pos * 2 + 1]; } PII& operator[](int pos) { return tree[pos + sz]; } int query() { return tree[1].ST; } } tree; int init(int N, int X[], int Y[]) { tree = Tree(N + 1); REP(i, N) tree[i + 1].ST = Y[i]; REP(i, N) tree[i].ND = X[i]; REP(i, N + 1) tree.update(i); return tree.query(); } int updateX(int pos, int val) { tree[pos].ND = val; tree.update(pos); return tree.query(); } int updateY(int pos, int val) { tree[++pos].ST = val; tree.update(pos); return tree.query(); }

Compilation message (stderr)

horses.cpp: In function 'int mul(int, int)':
horses.cpp:15:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return (long long) a * b % mod;
         ~~~~~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...