답안 #742504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742504 2023-05-16T10:57:20 Z Dan4Life 말 (IOI15_horses) C++17
17 / 100
15 ms 10508 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = (int)2e5+10;
const int MOD = (int)1e9+7;
struct Data{ double sum, ans; int i; } segTree[2*mxN];
ll n, X[mxN], Y[mxN], segTree2[mxN];

Data comb(Data &a, Data &b){
	Data c; c.sum = a.sum+b.sum;
	if(a.ans < a.sum+b.ans) c.i=b.i;
	else c.i = a.i;
	c.ans = max(a.ans, a.sum+b.ans);
	return c;
}

void upd2(int x, ll v, int p=0, int l=0, int r=n-1){
	if(l==r){ segTree2[p] = v; return; }
	int mid = (l+r)/2; int rp = p+2*(mid-l+1);
	if(x<=mid) upd2(x,v,p+1,l,mid);
	else upd2(x,v,rp,mid+1,r);
	segTree2[p] = (segTree2[p+1]*segTree2[rp])%MOD;
}

int query(int i, int j, int p=0, int l=0, int r=n-1){
	if(i>r or j<l or i>j) return 1;
	if(i<=l and r<=j) return segTree2[p];
	int mid = (l+r)/2; int rp = p+2*(mid-l+1);
	return (query(i,j,p+1,l,mid)*query(i,j,rp,mid+1,r))%MOD;
}

void upd(int x, ll v, int p=0, int l=0, int r=n-1){
	if(l==r){
		segTree[p] = {log(X[x]),log(X[x])+log(Y[x]),x};
		upd2(x,X[x]); return;
	}
	int mid = (l+r)/2; int rp = p+2*(mid-l+1);
	if(x<=mid) upd(x,v,p+1,l,mid);
	else upd(x,v,rp,mid+1,r);
	segTree[p] = comb(segTree[p+1],segTree[rp]);
}

int init(int N, int x[], int y[]) {
	n = N;
	for(int i = 0; i < n; i++){
		X[i] = x[i], Y[i] = y[i];
		upd(i,X[i]), upd(i,Y[i]);
	}
	int i = segTree[0].i;
	return (query(0,i)*Y[i])%MOD;
}

int updateX(int x, int v) {
	X[x] = v; upd(x,v);
	int i = segTree[0].i;
	return (query(0,i)*Y[i])%MOD;
}

int updateY(int x, int v) {
	Y[x] = v; upd(x,v);
	int i = segTree[0].i;
	return (query(0,i)*Y[i])%MOD;
}

Compilation message

horses.cpp:18:49: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   18 | void upd2(int x, ll v, int p=0, int l=0, int r=n-1){
      |                                                ~^~
horses.cpp:26:50: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   26 | int query(int i, int j, int p=0, int l=0, int r=n-1){
      |                                                 ~^~
horses.cpp: In function 'int query(int, int, int, int, int)':
horses.cpp:28:37: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |  if(i<=l and r<=j) return segTree2[p];
      |                           ~~~~~~~~~~^
horses.cpp: At global scope:
horses.cpp:33:48: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   33 | void upd(int x, ll v, int p=0, int l=0, int r=n-1){
      |                                               ~^~
horses.cpp: In function 'void upd(int, ll, int, int, int)':
horses.cpp:36:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   36 |   upd2(x,X[x]); return;
      |              ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:48:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   48 |   upd(i,X[i]), upd(i,Y[i]);
      |             ^
horses.cpp:48:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   48 |   upd(i,X[i]), upd(i,Y[i]);
      |                          ^
horses.cpp:51:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   51 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:51:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   51 |  return (query(0,i)*Y[i])%MOD;
      |         ~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:55:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   55 |  X[x] = v; upd(x,v);
      |                   ^
horses.cpp:57:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   57 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:57:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   57 |  return (query(0,i)*Y[i])%MOD;
      |         ~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:61:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   61 |  Y[x] = v; upd(x,v);
      |                   ^
horses.cpp:63:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   63 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:63:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   63 |  return (query(0,i)*Y[i])%MOD;
      |         ~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 1 ms 312 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 10508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 276 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -