제출 #988757

#제출 시각아이디문제언어결과실행 시간메모리
988757bigo말 (IOI15_horses)C++14
34 / 100
1586 ms524288 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <utility>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i,s,e) for(ll i=s;i<e;i++)
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const ll INF = 1e18;
typedef complex<double> cd;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const ll mod1 = 1e9 + 9;
const ll mod2 = 998244353;
const ll mac = 31;
const ll MAXN = 4e5 + 2;
typedef vector<int> vi;
typedef vector<vi> vvi;



ll cef(ll a, ll b) {
	ll val;
	if (ll(a) * ll(b) >= 1e9)
		val = 0;
	else
		val = a*b;
	return val;
}

struct seg {
	ll l, r, mid, val=1;
	seg* lp, * rp;
	seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
		if (l < r) {
			lp = new seg(l, mid);
			rp = new seg(mid+1,r);
		}
	}
	void pull() {
		val = cef(lp->val, rp->val);
	}
	void upd(ll i,ll x) {
		if (l == r) {
			val = x;
			return;
		}
		if (i <= mid) lp->upd(i, x);
		else rp->upd(i, x);
		pull();
	}
	ll que(ll a, ll b) {
		if (a <= l and r <= b) return val;
		if (a > r or l > b) return 1;
		return cef(lp->que(a, b),rp->que(a, b));
	}
};

int n;
vi x, y;

int init(int N, int X[], int Y[]) {
	n = N;
	x.resize(n);
	y.resize(n);
	rep(i, 0, n) x[i] = X[i], y[i] = Y[i];
	pair<ll, ll>ans = {0,(x[0]*y[0])%mod};
	ll c = x[0];
	seg segx(0, n - 1);
	rep(i, 1, n) {
		segx.upd(i, x[i]);
		c *= x[i];
		c %= mod;
		ll t = cef(segx.que(ans.first + 1, i), y[i]);
		if (t == 0 or t >= y[ans.first])
			ans = { i,(c * y[i]) % mod };
	}
	return ans.second;
}

int updateX(int pos, int val) {
	x[pos] = val;
	pair<ll, ll>ans = { 0,(x[0] * y[0]) % mod };
	ll c = x[0];
	seg segx(0, n - 1);
	rep(i, 1, n) {
		segx.upd(i, x[i]);
		c *= x[i];
		c %= mod;
		ll t = cef(segx.que(ans.first + 1, i), y[i]);
		if (t == 0 or t >= y[ans.first])
			ans = { i,(c * y[i]) % mod };
	}
	return ans.second;
}

int updateY(int pos, int val) {
	y[pos] = val;
	pair<ll, ll>ans = { 0,(x[0] * y[0]) % mod };
	ll c = x[0];
	seg segx(0, n - 1);
	rep(i, 1, n) {
		segx.upd(i, x[i]);
		c *= x[i];
		c %= mod;
		ll t = cef(segx.que(ans.first + 1, i), y[i]);
		if (t == 0 or t >= y[ans.first])
			ans = { i,(c * y[i]) % mod };
	}
	return ans.second;
}

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

horses.cpp: In function 'll cef(ll, ll)':
horses.cpp:25:12: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   25 |  if (ll(a) * ll(b) >= 1e9)
      |      ~~~~~~^~~~~~~
horses.cpp: In constructor 'seg::seg(ll, ll)':
horses.cpp:35:15: warning: declaration of 'r' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |            ~~~^
horses.cpp:33:8: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |        ^
horses.cpp:35:9: warning: declaration of 'l' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |      ~~~^
horses.cpp:33:5: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |     ^
horses.cpp: In constructor 'seg::seg(ll, ll)':
horses.cpp:35:15: warning: declaration of 'r' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |            ~~~^
horses.cpp:33:8: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |        ^
horses.cpp:35:9: warning: declaration of 'l' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |      ~~~^
horses.cpp:33:5: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |     ^
horses.cpp: In constructor 'seg::seg(ll, ll)':
horses.cpp:35:15: warning: declaration of 'r' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |            ~~~^
horses.cpp:33:8: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |        ^
horses.cpp:35:9: warning: declaration of 'l' shadows a member of 'seg' [-Wshadow]
   35 |  seg(ll l, ll r): l(l), r(r), mid((l + r) / 2) {
      |      ~~~^
horses.cpp:33:5: note: shadowed declaration is here
   33 |  ll l, r, mid, val=1;
      |     ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:79:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   79 |  return ans.second;
      |         ~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:95:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   95 |  return ans.second;
      |         ~~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:111:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  111 |  return ans.second;
      |         ~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:54:33: warning: 'segx.seg::rp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:86:6: note: 'segx.seg::rp' was declared here
   86 |  seg segx(0, n - 1);
      |      ^~~~
horses.cpp:54:33: warning: 'segx.seg::lp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:86:6: note: 'segx.seg::lp' was declared here
   86 |  seg segx(0, n - 1);
      |      ^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:54:33: warning: 'segx.seg::rp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:102:6: note: 'segx.seg::rp' was declared here
  102 |  seg segx(0, n - 1);
      |      ^~~~
horses.cpp:54:33: warning: 'segx.seg::lp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:102:6: note: 'segx.seg::lp' was declared here
  102 |  seg segx(0, n - 1);
      |      ^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:54:33: warning: 'segx.seg::rp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:70:6: note: 'segx.seg::rp' was declared here
   70 |  seg segx(0, n - 1);
      |      ^~~~
horses.cpp:54:33: warning: 'segx.seg::lp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |   if (a <= l and r <= b) return val;
      |                                 ^~~
horses.cpp:70:6: note: 'segx.seg::lp' was declared here
   70 |  seg segx(0, n - 1);
      |      ^~~~
#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...