제출 #343556

#제출 시각아이디문제언어결과실행 시간메모리
343556NhatMinh0208말 (IOI15_horses)C++14
0 / 100
574 ms36116 KiB
/*
	Normie's Template v2.0
*/
 
// Standard library in one include.
#include <bits/stdc++.h>
using namespace std;
 
// ordered_set library.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set(el) tree<el,null_type,less<el>,rb_tree_tag,tree_order_statistics_node_update>
 
// AtCoder library. (Comment out these two lines if you're not submitting in AtCoder.) (Or if you want to use it in other judges, run expander.py first.)
//#include <atcoder/all>
//using namespace atcoder;
 
//Pragmas (Comment out these three lines if you're submitting in szkopul.)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//File I/O.
#define FILE_IN "cseq.inp"
#define FILE_OUT "cseq.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
 
//Fast I/O.
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define endl "\n"
 
//Order checking.
#define ord(a,b,c) ((a>=b)and(b>=c))
 
//min/max redefines, so i dont have to resolve annoying compile errors.
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
 
//Constants.
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 320
 
//Pairs and 3-pairs.
#define p1 first
#define p2 second.first
#define p3 second.second
#define fi first
#define se second
#define pii(element_type) pair<element_type,element_type>
#define piii(element_type) pair<element_type,pii(element_type)>
 
//Quick power of 2.
#define pow2(x) (ll(1)<<x)
 
//Short for-loops.
#define ff(i,__,___) for(int i=__;i<=___;i++)
#define rr(i,__,___) for(int i=__;i>=___;i--)
 
//Typedefs.
#define bi BigInt
typedef long long ll;
typedef long double ld;
typedef short sh;
//---------END-------//
#include "horses.h"
int bow(int a, int x, int p)
{
	if (!x) return 1;
	ll res=bow(a,x/2,p);
	res*=res;
	res%=p;
	if (x%2)
	{
		res*=a;
		res%=p;
	}
	return res;
};
struct seg
{
	int val[2000001];
	void update(int l, int r, int cur, int x, int d)
	{
	//	cout<<"update "<<l<<' '<<r<<' '<<cur<<' '<<x<<' '<<d<<endl;
		if ((l<=x)and(x<=r))
		{
			if (l==r)
			{
				val[cur]=d;
			}
			else
			{
				int mid=(l+r)/2;
				update(l,mid,(cur<<1),x,d);
				update(mid+1,r,(cur<<1)+1,x,d);
				val[cur]=max(val[(cur<<1)],val[(cur<<1)+1]);
			}
		}
	}
	int get(int l, int r, int cur, int tl, int tr)
	{
	//	cout<<"update "<<l<<' '<<r<<' '<<cur<<' '<<tl<<' '<<tr<<endl;
		if ((tl>r)or(tr<l)) return 0;
		if ((tl<=l)and(tr>=r)) return val[cur];
		else
		{
			int mid=(l+r)/2;
			
			int a=get(l,mid,(cur<<1),tl,tr);
			int b=get(mid+1,r,(cur<<1)+1,tl,tr);
			return (max(a,b));
		}
	}
};
seg st;
int x[500001],y[500001];
ll inv[500001];
int n,m,i,j,k,t,t1,u,v,a,b;
set<int,greater<int>> g1;
ll co=1;
ll maxx=1,modd;
ll cur,left;
ll ask()
{
//	cout<<"value of co:"<<co<<endl;
//	cout<<"---------arrray-----------"<<endl;
//	for (int i=0;i<n;i++) cout<<x[i]<<' '<<y[i]<<endl;
//	cout<<"--------------------------"<<endl;
	cur=co;
	maxx=0;
	modd=0;
	for (int g : g1)
	{
		u=st.get(0,n-1,1,g,n-1);
//		cout<<g<<' '<<maxx<<' '<<modd<<' '<<u<<' '<<cur<<endl;
		if (maxx<u)
		{
			maxx=u;
			modd=ll(u)*cur;
			modd%=MOD;
		}
		if (g==-1) break;
		maxx*=x[g];
		if (maxx>1e9) break;
		cur*=inv[g];
		cur%=MOD;
	}
	return modd;
}
int init(int N, int X[], int Y[]) {
	n=N;
	for (i=0;i<N;i++)
	{
		x[i]=X[i];
		y[i]=Y[i];
		st.update(0,n-1,1,i,Y[i]);
		if (X[i]>1) g1.insert(i);
		co*=X[i];
		co%=MOD;
	}
	g1.insert(-1);
	return ask();
}
int updateX(int pos, int val) {	
	co*=bow(x[pos],MOD-2,MOD);
	co%=MOD;
	co*=val;
	co%=MOD;
	if (x[pos]>1) g1.erase(pos);
	x[pos]=val;
	inv[pos]=bow(x[pos],MOD-2,MOD);
	if (x[pos]>1) g1.insert(pos);
	return ask();
}
int updateY(int pos, int val) {
	st.update(0,n-1,1,pos,val);
	return ask();
}

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

horses.cpp:20: warning: ignoring #pragma comment  [-Wunknown-pragmas]
   20 | #pragma comment(linker, "/stack:200000000")
      | 
horses.cpp: In function 'int bow(int, int, int)':
horses.cpp:80:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   80 |  return res;
      |         ^~~
horses.cpp: In function 'll ask()':
horses.cpp:147:7: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
  147 |   if (maxx>1e9) break;
      |       ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:165:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  165 |  return ask();
      |         ~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:176:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  176 |  return ask();
      |         ~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:180:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  180 |  return ask();
      |         ~~~^~
#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...