Submission #91520

#TimeUsernameProblemLanguageResultExecution timeMemory
91520turbatHorses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; #define N 500005 long long mod = 1e9 + 7, n, x[N], y[N]; struct segment{ int ans, mul; double a = 0, m = 0; } s[4 * N]; void update(int node, int l, int r, int idx, int valx, int valy){ if (idx < l || r < idx) return; if (l == r){ if (valx) x[l] = valx; if (valy) y[l] = valy; s[node].ans = (1ll * x[l] * y[l]) % mod; s[node].mul = x[l]; s[node].m = log10(x[l]); s[node].a = log(1ll * x[l] * y[l]); return; } int mid = (l + r)/2; update(node * 2, l, mid, idx, int valx, int valy); update(node * 2 + 1, mid + 1, r, idx, int valx, int valy); s[node].m = s[node * 2].m + s[node * 2 + 1].m; s[node].mul = (1ll * s[node * 2].mul * s[node * 2 + 1].mul) % mod; if (s[node * 2].a > s[node * 2 + 1].a + s[node * 2].m){ s[node].ans = s[node * 2].ans; s[node].a = s[node * 2].a; } else{ s[node].ans = (1ll * s[node * 2 + 1].ans * s[node * 2].mul ) % mod; s[node].a = s[node * 2 + 1].a + s[node * 2].m; } } int init(int N, int X[], int Y[]) { n = N; for (int i = 0;i < n;i++) update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]); return s[1].ans; } int updateX(int pos, int val) { update(1, 0, n - 1, pos, val, 0); return s[1].ans; } int updateY(int pos, int val) { update(1, 0, n - 1, pos, 0, val); return s[1].ans; }

Compilation message (stderr)

horses.cpp: In function 'void update(int, int, int, int, int, int)':
horses.cpp:15:37: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   s[node].ans = (1ll * x[l] * y[l]) % mod;
                 ~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:16:20: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   s[node].mul = x[l];
                 ~~~^
horses.cpp:22:32: error: expected primary-expression before 'int'
  update(node * 2, l, mid, idx, int valx, int valy);
                                ^~~
horses.cpp:22:42: error: expected primary-expression before 'int'
  update(node * 2, l, mid, idx, int valx, int valy);
                                          ^~~
horses.cpp:23:40: error: expected primary-expression before 'int'
  update(node * 2 + 1, mid + 1, r, idx, int valx, int valy);
                                        ^~~
horses.cpp:23:50: error: expected primary-expression before 'int'
  update(node * 2 + 1, mid + 1, r, idx, int valx, int valy);
                                                  ^~~
horses.cpp:25:62: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  s[node].mul = (1ll * s[node * 2].mul * s[node * 2 + 1].mul) % mod;
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:31:64: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   s[node].ans = (1ll * s[node * 2 + 1].ans * s[node * 2].mul ) % mod;
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: At global scope:
horses.cpp:4:11: error: expected ',' or '...' before numeric constant
 #define N 500005
           ^
horses.cpp:35:14: note: in expansion of macro 'N'
 int init(int N, int X[], int Y[]) {
              ^
horses.cpp: In function 'int init(int)':
horses.cpp:38:23: error: 'pos' was not declared in this scope
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                       ^~~
horses.cpp:38:23: note: suggested alternative: 'pow'
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                       ^~~
                       pow
horses.cpp:38:28: error: 'X' was not declared in this scope
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                            ^
horses.cpp:38:34: error: 'Y' was not declared in this scope
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                                  ^
horses.cpp:38:40: error: 'cnt' was not declared in this scope
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                                        ^~~
horses.cpp:38:40: note: suggested alternative: 'int'
   update(1, 0, n - 1, pos, X[i], Y[i], cnt[i]);
                                        ^~~
                                        int
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:42:17: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  update(1, 0, n - 1, pos, val, 0);
               ~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:46:17: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  update(1, 0, n - 1, pos, 0, val);
               ~~^~~