제출 #210909

#제출 시각아이디문제언어결과실행 시간메모리
210909autumn_eel말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include "horses.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; const int MOD=1000000007; ll ppow(ll a,ll b){ ll res=1; while(b){ if(b&1)res=(res*a)%MOD; a=(a*a)%MOD; b>>=1; } return res; } struct BIT{ vector<ll>bit; BIT(){} BIT(int n){ n=n+10; bit=vector<ll>(n,1); } void add(int k,ll x){ k++; while(k<bit.size()){ (bit[k]*=x)%=MOD; k+=k&-k; } } ll sum(int k){//[0,k) ll res=1; while(k){ (res*=bit[k])%=MOD; k-=k&-k; } return res; } }bit; struct Segtree{ int N; vector<int>dat; Segtree(){} Segtree(int n){ N=1;while(N<n)N<<=1; dat=vector<int>(2*N); } void update(int k,int x){ k+=N;dat[k]=x; while(k>1){ k>>=1; dat[k]=max(dat[k*2],dat[k*2+1]); } } int query(int l,int r){ int res=0; for(l+=N,r+=N;l<r;l>>=1,r>>=1){ if(l&1)res=max(res,dat[l++]); if(r&1)res=max(res,dat[--r]); } return res; } }seg; int n; ll x[600000],y[600000]; set<int>se; ll calc(){ if(se.empty())return seg.query(0,n)%MOD; ll res=0; ll M=1; auto s=--se.end(); while(1){ M*=x[*s]; if(M>1e9||s==se.begin())break; s--; } __int128 Max=0,cur=1; for(auto it=s;it!=se.end();it++){ cur*=x[*it]; ll d=seg.query(*it,(it==--se.end()?n:*next(it))); assert(log2(cur)+log2(d)<=100); Max=max(Max,cur*d); } Max%=MOD; Max*=bit.sum(*s); return Max%MOD; } int init(int N, int X[], int Y[]) { n=N; bit=BIT(n);seg=Segtree(n); rep(i,n){ x[i]=X[i],y[i]=Y[i]; bit.add(i,x[i]); seg.update(i,y[i]); if(x[i]>1)se.insert(i); } return (int)calc(); } int updateX(int pos, int val) { bit.add(pos,ppow(x[pos],MOD-2)*val%MOD); if(val==1){ se.erase(pos); } else{ se.insert(pos); } x[pos]=val; return (int)calc(); } int updateY(int pos, int val) { y[pos]=val; seg.update(pos,val); return (int)calc(); }

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

horses.cpp: In member function 'void BIT::add(int, ll)':
horses.cpp:28:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(k<bit.size()){
         ~^~~~~~~~~~~
horses.cpp: In function 'll calc()':
horses.cpp:80:8: warning: conversion to 'double' from 'll {aka long long int}' may alter its value [-Wconversion]
   if(M>1e9||s==se.begin())break;
        ^~~
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from horses.cpp:2:
horses.cpp:87:18: error: call of overloaded 'log2(__int128&)' is ambiguous
   assert(log2(cur)+log2(d)<=100);
                  ^
In file included from /usr/include/features.h:367:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533,
                 from /usr/include/c++/7/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from horses.cpp:2:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:144:1: note: candidate: double log2(double)
 __MATHCALL (log2,, (_Mdouble_ __x));
 ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41:0,
                 from horses.cpp:2:
/usr/include/c++/7/cmath:1585:3: note: candidate: constexpr float std::log2(float)
   log2(float __x)
   ^~~~
/usr/include/c++/7/cmath:1589:3: note: candidate: constexpr long double std::log2(long double)
   log2(long double __x)
   ^~~~
horses.cpp:92:12: warning: conversion to 'll {aka long long int}' from '__int128' may alter its value [-Wconversion]
  return Max%MOD;
         ~~~^~~~
horses.cpp:75:5: warning: unused variable 'res' [-Wunused-variable]
  ll res=0;
     ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:101:19: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   seg.update(i,y[i]);
                ~~~^