제출 #262389

#제출 시각아이디문제언어결과실행 시간메모리
262389uacoder123말 (IOI15_horses)C++14
17 / 100
1593 ms75640 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) lli(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; pair<lli,int> segt[2000001]; lli lazy[2000001],arr1[500001],arr2[500001],segt1[2000001]; lli n,mod=1000000007; lli p(lli a) { lli b=0,ans=1; while((1LL<<b)<=mod-2) { if(bit(mod-2,b)) ans=(ans*a)%mod; a=(a*a)%mod; b++; } return ans; } void up1(lli node,lli l,lli r,lli in,lli v) { if(l==r) { segt1[node]=(v)%mod; return; } lli m=(l+r)/2; if(in<=m) up1(2*node+1,l,m,in,v); else up1(2*node+2,m+1,r,in,v); segt1[node]=min(mod,segt1[2*node+1]*segt1[2*node+2]); } lli qu(lli node,lli l,lli r,lli s,lli e) { if(l>e||r<s) return(1); if(l>=s&&r<=e) return segt1[node]; lli m=(l+r)/2; lli q1=qu(2*node+1,l,m,s,e),q2=qu(2*node+2,m+1,r,s,e); return min(q1*q2,mod); } void up(lli node,lli l,lli r,lli s,lli e,lli v) { if(l>e||r<s) return; if(lazy[node]!=1) { segt[node].F=(segt[node].F*lazy[node])%mod; if(l!=r) { lazy[2*node+1]=(lazy[2*node+1]*lazy[node])%mod; lazy[2*node+2]=(lazy[2*node+2]*lazy[node])%mod; } lazy[node]=1; } if(l>=s&&r<=e) { if(l==r) segt[node].S=l; segt[node].F=(segt[node].F*v)%mod; if(l!=r) { lazy[2*node+1]=(lazy[2*node+1]*v)%mod; lazy[2*node+2]=(lazy[2*node+2]*v)%mod; } return; } lli m=(l+r)/2; up(2*node+1,l,m,s,e,v); up(2*node+2,m+1,r,s,e,v); lli q=qu(0,0,n-1,segt[2*node+1].S+1,segt[2*node+2].S); if(q*arr2[segt[2*node+2].S]<arr2[segt[2*node+1].S]) segt[node]=segt[2*node+1]; else segt[node]=segt[2*node+2]; } int init(int N, int X[], int Y[]) { for(lli i=0;i<=2000001;++i) { segt[i].F=1; segt1[i]=1; lazy[i]=1; } n=N; lli cur=(1); for(int i=0;i<n;++i) { arr1[i]=X[i]; arr2[i]=Y[i]; up1(0,0,n-1,i,X[i]); } for(lli i=0;i<n;++i) { cur=(cur*X[i])%mod; up(0,0,n-1,i,i,(cur*Y[i])%mod); } return segt[0].F; } int updateX(int pos, int val) { lli v=p(arr1[pos]); v=(v*val)%mod; arr1[pos]=val; up1(0,0,n-1,pos,val); up(0,0,n-1,pos,n-1,v); return segt[0].F; } int updateY(int pos, int val) { lli v=p(arr2[pos]); v=(v*val)%mod; arr2[pos]=val; up(0,0,n-1,pos,pos,v); return segt[0].F; }

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

horses.cpp: In function 'lli p(lli)':
horses.cpp:27:15: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   27 |     if(bit(mod-2,b))
      |            ~~~^~
horses.cpp:12:19: note: in definition of macro 'bit'
   12 | #define bit(x,b) (x&(1LL<<b))
      |                   ^
horses.cpp: In function 'void up(lli, lli, lli, lli, lli, lli)':
horses.cpp:75:20: warning: conversion from 'lli' {aka 'long long int'} to 'int' may change value [-Wconversion]
   75 |       segt[node].S=l;
      |                    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:4:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    4 | #define F first
      |           ^
horses.cpp:114:18: note: in expansion of macro 'F'
  114 |   return segt[0].F;
      |                  ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:4:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    4 | #define F first
      |           ^
horses.cpp:124:18: note: in expansion of macro 'F'
  124 |   return segt[0].F;
      |                  ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:4:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    4 | #define F first
      |           ^
horses.cpp:132:18: note: in expansion of macro 'F'
  132 |   return segt[0].F;
      |                  ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:97:14: warning: iteration 2000001 invokes undefined behavior [-Waggressive-loop-optimizations]
   97 |     segt[i].F=1;
      |     ~~~~~~~~~^~
horses.cpp:95:16: note: within this loop
   95 |   for(lli i=0;i<=2000001;++i)
      |               ~^~~~~~~~~
#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...