제출 #485609

#제출 시각아이디문제언어결과실행 시간메모리
485609MilosMilutinovic말 (IOI15_horses)C++14
17 / 100
19 ms14760 KiB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const ll mod2=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

ll mul(ll a, ll b) {
	return a*b%mod;
}

const int N=201000;
int a[N],b[N];
db ps[N];
ll pp[N];

struct node {
	db mx,lzy;
	ll f,lzyp;
}nd[4*N];

void upd(int p) {
	if (nd[p+p].mx>nd[p+p+1].mx) {
		nd[p]=nd[p+p];
	} else {
		nd[p]=nd[p+p+1];
	}
}

void push(int p) {
	nd[p].mx+=nd[p].lzy;
	nd[p].f=mul(nd[p].f,nd[p].lzyp);
	nd[p+p].lzy+=nd[p].lzy;
	nd[p+p+1].lzy+=nd[p].lzy;
	nd[p+p].lzyp=mul(nd[p+p].lzyp,nd[p].lzyp);
	nd[p+p+1].lzyp=mul(nd[p+p+1].lzyp,nd[p].lzyp);
	nd[p].lzy=0;
	nd[p].lzyp=1;
}

void build(int p,int l,int r) {
	nd[p].lzyp=1;
	if (l==r) {
		nd[p].mx=ps[l]+log10(b[l]);
		nd[p].f=mul(pp[l],b[l]);
		return;
	}
	int md=l+r>>1;
	build(p+p,l,md);
	build(p+p+1,md+1,r);
	upd(p);
}

void modify(int p,int l,int r,int ql,int qr,db x,ll y) {
	push(p);
	if (l>qr||r<ql) return;
	if (ql<=l&&r<=qr) {
		nd[p].lzy+=x;
		nd[p].lzyp=mul(nd[p].lzyp,y);
		push(p);
		return;
	}
	int md=l+r>>1;
	modify(p+p,l,md,ql,qr,x,y);
	modify(p+p+1,md+1,r,ql,qr,x,y);
	upd(p);
}

int init(int n,int* x,int* y) {
	ps[0]=0; pp[0]=1;
	rep(i,1,n+1) ps[i]=ps[i-1]+log10(x[i-1]);
	rep(i,1,n+1) pp[i]=mul(pp[i-1],x[i-1]);
	rep(i,1,n+1) a[i]=x[i-1],b[i]=y[i-1];
	build(1,1,n);
	return nd[1].f;
}

int updateX(int pos,int val) {
	assert(false);
	return 0;
}

int updateY(int pos,int val) {
	assert(false);
	return 0;
}

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

horses.cpp: In function 'int rnd(int)':
horses.cpp:18:33: warning: conversion from 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   18 | int rnd(int x) { return mrand() % x;}
      |                         ~~~~~~~~^~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:63:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |  int md=l+r>>1;
      |         ~^~
horses.cpp: In function 'void modify(int, int, int, int, int, db, ll)':
horses.cpp:78:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   78 |  int md=l+r>>1;
      |         ~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:90:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   90 |  return nd[1].f;
      |         ~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:93:17: warning: unused parameter 'pos' [-Wunused-parameter]
   93 | int updateX(int pos,int val) {
      |             ~~~~^~~
horses.cpp:93:25: warning: unused parameter 'val' [-Wunused-parameter]
   93 | int updateX(int pos,int val) {
      |                     ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:98:17: warning: unused parameter 'pos' [-Wunused-parameter]
   98 | int updateY(int pos,int val) {
      |             ~~~~^~~
horses.cpp:98:25: warning: unused parameter 'val' [-Wunused-parameter]
   98 | int updateY(int pos,int val) {
      |                     ~~~~^~~
#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...