제출 #1004415

#제출 시각아이디문제언어결과실행 시간메모리
1004415HasanV11010238말 (IOI15_horses)C++17
0 / 100
37 ms56092 KiB
#include "horses.h" #include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; int n; vector<ll> x, y, tr; void build(int v, int l, int r){ if (l == r){ tr[v] = x[l]; } int mid = (l + r) / 2; build(v * 2, l, mid); build(v * 2, mid + 1, r); tr[v] = (tr[v * 2] * tr[v * 2 + 1]) % mod; } void update(int v, int l, int r, int pos, ll val){ if (l == r){ tr[v] = val; } else{ int mid = (l + r) / 2; if (pos <= mid){ update(v * 2, l, mid, pos, val); } else{ update(v * 2 + 2, mid + 1, r, pos, val); } tr[v] = (tr[v * 2] * tr[v * 2 + 1]) % mod; } } ll query(int v, int l, int r, int ql, int qr){ if (l > qr || r < ql){ return 1; } else if (ql <= l && r <= qr){ return tr[v]; } int mid = (l + r) / 2; return (query(v * 2, l, mid, ql, qr) * query(v * 2 + 1, mid + 1, r, ql, qr)) % mod; } ll calc(){ ll ti = 1, in = n - 1; for (int i = n - 1; i >= 0; i++){ ti *= x[i]; if (ti < mod){ in--; } else{ break; } } ll ma = 0; ll prmult = 1; for (int i = 0; i < n; i++){ prmult *= x[i]; ma = max(ma, 1ll * prmult * y[i]); } ll ext = 1; if (ti != 0){ ext = query(1, 0, n - 1, 0, ti - 1); } return ((ma % mod) * ext) % mod; } int init(int N, int X[], int Y[]) { n = N; x.resize(N), y.resize(N), tr.assign(N * 4, 1); for (int i = 0; i < N; i++){ x[i] = X[i]; y[i] = Y[i]; } build(1, 0, n - 1); return calc(); } int updateX(int pos, int val){ x[pos] = val; update(1, 0, n - 1, pos, val); return calc(); } int updateY(int pos, int val){ y[pos] = val; return calc(); }

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

horses.cpp: In function 'long long int calc()':
horses.cpp:61:34: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   61 |   ext = query(1, 0, n - 1, 0, ti - 1);
      |                               ~~~^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:73:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   73 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:79:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   79 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:84:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   84 |  return calc();
      |         ~~~~^~
#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...