Submission #393213

#TimeUsernameProblemLanguageResultExecution timeMemory
393213Kenzo_1114Horses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 500010; const long long int MOD = 1e9 + 7; int n; long long int x[MAXN], y[MAXN]; long long int seg[4 * MAXN], lz[4 * MAXN]; void refresh(int pos, int bg, int ed) { if(lz[pos] == 1) return; long long int Lz = lz[pos]; lz[pos] = 1; seg[pos] = (seg[pos] * Lz) % MOD; if(bg == ed) return; int mid = (bg + ed) >> 1, l = 2 * pos, r = l + 1; lz[l] = (lz[l] * Lz) % MOD; lz[r] = (lz[r] * Lz) % MOD; } void upd(int pos, int bg, int ed, int p, int q, long long int val) { refresh(pos, bg, ed); if(q < p || q < bg || ed < p) return; if(p <= bg && ed <= q) { lz[pos] = (lz[pos] * val) % MOD; refresh(pos, bg, ed); return; } int mid = (bg + ed) >> 1, l = 2 * pos, r = l + 1; upd(l, bg, mid, p, q, val); upd(r, mid + 1, ed, p, q, val); seg[pos] = max(seg[l], seg[r]); } long long int fe(long long int a, long long int p) { if(p == 0) return 1; if(p == 1) return a; long long int b = fe(a, p / 2); b = (b * b) % MOD; if(p & 1) b = (b * a) % MOD; return b; } int updateX(int pos, long long int val) { pos++; upd(1, 1, n, pos, n, fe(x[pos], MOD - 2)); x[pos] = val; upd(1, 1, n, pos, n, x[pos]); refresh(1, 1, n); return seg[1]; } int updateY(int pos, long long int val) { pos++; upd(1, 1, n, pos, pos, fe(y[pos], MOD - 2)); y[pos] = val; upd(1, 1, n, pos, pos, y[pos]); refresh(1, 1, n); return seg[1]; } int init(int N, long long int X[], long long int Y[]) { n = N; for(int i = n; i > 0; i--) x[i] = X[i - 1]; for(int i = n; i > 0; i--) y[i] = Y[i - 1]; for(int i = 1; i < 4 * MAXN; i++) lz[i] = 1, seg[i] = 1; for(int i = 1; i <= n; i++) { upd(1, 1, n, i, n, x[i]); upd(1, 1, n, i, i, y[i]); } refresh(1, 1, n); return seg[1]; } /* int N; long long int X[MAXN], Y[MAXN]; int main () { scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%lld", &X[i]); for(int i = 0; i < N; i++) scanf("%lld", &Y[i]); printf("%d\n", init(N, X, Y)); printf("%d\n", updateY(1, 2)); } 3 2 1 3 3 4 1 */

Compilation message (stderr)

horses.cpp: In function 'void refresh(int, int, int)':
horses.cpp:19:6: warning: unused variable 'mid' [-Wunused-variable]
   19 |  int mid = (bg + ed) >> 1, l = 2 * pos, r = l + 1;
      |      ^~~
horses.cpp: In function 'int updateX(int, long long int)':
horses.cpp:63:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   63 |  return seg[1];
      |         ~~~~~^
horses.cpp: In function 'int updateY(int, long long int)':
horses.cpp:74:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   74 |  return seg[1];
      |         ~~~~~^
horses.cpp: In function 'int init(int, long long int*, long long int*)':
horses.cpp:92:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   92 |  return seg[1];
      |         ~~~~~^
/tmp/ccJWwC0R.o: In function `main':
grader.c:(.text.startup+0x360): undefined reference to `init(int, int*, int*)'
grader.c:(.text.startup+0x903): undefined reference to `updateX(int, int)'
grader.c:(.text.startup+0x97f): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status