제출 #380190

#제출 시각아이디문제언어결과실행 시간메모리
380190idk321말 (IOI15_horses)C++11
57 / 100
1592 ms5228 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1000000007; const int N = 500000; const int R = 710; int n; int* x; int* y; int best[R]; ll left1[R]; ll right1[R]; void spMod(ll& num) { if (num >= mod) { num %= mod; num += mod; } } ll getBest() { int ci = best[0]; ll fac = 1; fac *= right1[0]; spMod(fac); ll facAll = left1[0]; facAll %= mod; facAll *= right1[0]; facAll %= mod; for (int a = R; a < n; a += R) { int i = best[a / R]; fac *= left1[a / R]; spMod(fac); if (fac * y[i] > y[ci]) { ci = i; fac = 1; } fac *= right1[a / R]; spMod(fac); } ll res = 1; for (int i = 0; i < ci / R; i++) { res *= left1[i]; res %= mod; res *= right1[i]; res %= mod; } res *= left1[ci / R]; res %= mod; res *= y[ci]; res %= mod; return res; } void makeBlock(int block) { int ci = block * R; ll fac = 1; for (int i = block * R + 1; i < min(n, (block + 1) * R); i++) { fac *= x[i]; spMod(fac); if (fac > y[ci] || fac * y[i] > y[ci]) { ci = i; fac = 1; } } fac = 1; for (int i = 0; i <= ci % R; i++) { fac *= x[i + block * R]; spMod(fac); } left1[block] = fac; fac = 1; for (int i = R - 1; i > ci % R; i--) { if (i + block * R >= n) continue; fac *= x[i + block * R]; spMod(fac); } right1[block] = fac; best[block] = ci; } int init(int N, int X[], int Y[]) { n = N; x = X; y = Y; for (int a = 0; a < R && a * R < n; a++) { makeBlock(a); } //cout << best[0] << endl; return getBest() % mod; } int updateX(int pos, int val) { x[pos] = val; makeBlock(pos / R); return getBest() % mod; } int updateY(int pos, int val) { y[pos] = val; makeBlock(pos / R); return getBest() % mod; }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:119:33: warning: declaration of 'N' shadows a global declaration [-Wshadow]
  119 | int init(int N, int X[], int Y[]) {
      |                                 ^
horses.cpp:9:11: note: shadowed declaration is here
    9 | const int N = 500000;
      |           ^
horses.cpp:130:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  130 |     return getBest() % mod;
      |            ~~~~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:140:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  140 |     return getBest() % mod;
      |            ~~~~~~~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:149:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  149 |     return getBest() % 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...