제출 #830330

#제출 시각아이디문제언어결과실행 시간메모리
830330Supersonic말 (IOI15_horses)C++14
34 / 100
1594 ms23916 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; ll h[500001]; ll x[500001]; ll y[500001]; bool subtask3=1; int n; ll tree[1048577]; void modify(int k, int x) { k += n; tree[k] = x; for (k /= 2; k >= 1; k /= 2) { tree[k] = tree[2*k]*tree[2*k+1]; tree[k]%=((ll)1e9+7); } } ll prod(ll a, ll b) { a += n; b += n; ll s = 1; while (a <= b) { if (a%2 == 1) {s *= tree[a++];s%=((ll)1e9+7);} if (b%2 == 0) {s *= tree[b--];s%=((ll)1e9+7);} a /= 2; b /= 2; } return s; } int init(int N, int X[], int Y[]) { n=N; h[0]=X[0]; //if(n<=1000)subtask3=0; for(int i=0;i<n;i++){ if(x[i]<2)subtask3=0; x[i]=X[i]; modify(i,x[i]); y[i]=Y[i]; if(i>0)h[i]=(h[i-1]*x[i])%((ll)1e9+7); } //cout<<prod(0,2)<<endl;; if(!subtask3){ ll mp=0;ll c=1; for(int i=1;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (h[mp]*y[mp])%((ll)1e9+7); } else{ ll mp=n-101;ll c=1; for(int i=n-100;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (h[mp]*y[mp])%((ll)1e9+7); } } int updateX(int pos, int val) { if(!subtask3){ x[pos]=val; modify(pos,val); h[0]=x[0]; for(int i=1;i<n;i++){ if(i<pos)continue; h[i]=(h[i-1]*x[i])%((ll)1e9+7); } ll mp=0;ll c=1; for(int i=1;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (prod(0,mp)*y[mp])%((ll)1e9+7); } else{ x[pos]=val; modify(pos,val); h[0]=x[0]; for(int i=n-101;i<n;i++){ if(i<pos)continue; h[i]=(h[i-1]*x[i])%((ll)1e9+7); } ll mp=n-101;ll c=1; for(int i=n-100;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (h[mp]*y[mp])%((ll)1e9+7); } } int updateY(int pos, int val) { if(!subtask3){ y[pos]=val; ll mp=0;ll c=1; for(int i=1;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (h[mp]*y[mp])%((ll)1e9+7); } else{ y[pos]=val; ll mp=0;ll c=1; for(int i=n-100;i<n;i++){ c*=x[i]; if(c>y[mp]||y[i]>y[mp]||c*y[i]>y[mp]){mp=i;c=1;} } return (h[mp]*y[mp])%((ll)1e9+7); } }

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

horses.cpp: In function 'void modify(int, int)':
horses.cpp:11:24: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   11 | void modify(int k, int x) {
      |                    ~~~~^
horses.cpp:6:4: note: shadowed declaration is here
    6 | ll x[500001];
      |    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:38:15: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   38 |   modify(i,x[i]);
      |            ~~~^
horses.cpp:49:23: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   49 |   return (h[mp]*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:57:23: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   57 |   return (h[mp]*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:75:28: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   75 |   return (prod(0,mp)*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:90:23: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
   90 |   return (h[mp]*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:103:23: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
  103 |   return (h[mp]*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
horses.cpp:112:23: warning: conversion from 'll' {aka 'long long unsigned int'} to 'int' may change value [-Wconversion]
  112 |   return (h[mp]*y[mp])%((ll)1e9+7);
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~
#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...