답안 #1030267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030267 2024-07-22T01:49:59 Z pcc 말 (IOI15_horses) C++17
34 / 100
602 ms 12380 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
const ll mod = 1e9+7;
const ll mxn = 1010;
const ll inf = 1e9+10;

ll pref[mxn];
ll N;
ll arr[mxn],brr[mxn];

struct SEG{
#define ls now*2+1
#define rs now*2+2
#define mid ((l+r)>>1)
	ll seg[mxn*4];
	void build(int now,int l,int r){
		if(l == r){
			seg[now] = arr[l];
			return;
		}
		build(ls,l,mid);
		build(rs,mid+1,r);
		seg[now] = seg[ls]*seg[rs];
		if(seg[now]>=mod)seg[now] = mod+seg[now]%mod;
		return;
	}
	void modify(int now,int l,int r,int p,ll v){
		if(l == r){
			seg[now] = v;
			return;
		}
		if(mid>=p)modify(ls,l,mid,p,v);
		else modify(rs,mid+1,r,p,v);
		seg[now] = seg[ls]*seg[rs];
		if(seg[now]>=mod)seg[now] = mod+seg[now]%mod;
	}
	ll getval(int now,int l,int r,int s,int e){
		if(l>=s&&e>=r)return seg[now];
		if(mid>=e)return getval(ls,l,mid,s,e);
		else if(mid<s)return getval(rs,mid+1,r,s,e);
		else{
			auto re = getval(ls,l,mid,s,e)*getval(rs,mid+1,r,s,e);
			if(re>=mod)return mod+re%mod;
			else return re;
		}
	}
#undef ls
#undef rs
#undef mid
};

SEG seg;

bool cmp(int a,int b){
	if(a>b)return brr[a]*seg.getval(0,0,N-1,b+1,a)<brr[b];
	else return brr[a]<brr[b]*seg.getval(0,0,N-1,a+1,b);
}

ll getans(){
	vector<int> v(N);
	iota(v.begin(),v.end(),0);
	sort(v.begin(),v.end(),cmp);
	return seg.getval(0,0,N-1,0,v.back())*brr[v.back()]%mod;
}

int init(int NN, int X[], int Y[]) {
	N = NN;
	for(int i = 0;i<N;i++){
		arr[i] = X[i];
		brr[i] = Y[i];
	}
	seg.build(0,0,N-1);
	return getans();
}

int updateX(int pos, int val) {	
	seg.modify(0,0,N-1,pos,arr[pos]=val);
	return getans();
}

int updateY(int pos, int val) {
	brr[pos] = val;
	return getans();
}

Compilation message

horses.cpp: In function 'bool cmp(int, int)':
horses.cpp:61:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   61 |  if(a>b)return brr[a]*seg.getval(0,0,N-1,b+1,a)<brr[b];
      |                                      ~^~
horses.cpp:62:44: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   62 |  else return brr[a]<brr[b]*seg.getval(0,0,N-1,a+1,b);
      |                                           ~^~
horses.cpp: In function 'long long int getans()':
horses.cpp:69:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   69 |  return seg.getval(0,0,N-1,0,v.back())*brr[v.back()]%mod;
      |                        ~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:78:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   78 |  seg.build(0,0,N-1);
      |                ~^~
horses.cpp:79:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   79 |  return getans();
      |         ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:83:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   83 |  seg.modify(0,0,N-1,pos,arr[pos]=val);
      |                 ~^~
horses.cpp:84:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   84 |  return getans();
      |         ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:89:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   89 |  return getans();
      |         ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 388 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 392 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 593 ms 484 KB Output is correct
24 Correct 578 ms 344 KB Output is correct
25 Correct 537 ms 492 KB Output is correct
26 Correct 511 ms 344 KB Output is correct
27 Correct 594 ms 480 KB Output is correct
28 Correct 472 ms 348 KB Output is correct
29 Correct 395 ms 344 KB Output is correct
30 Correct 478 ms 344 KB Output is correct
31 Correct 395 ms 344 KB Output is correct
32 Correct 393 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 8540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 597 ms 492 KB Output is correct
24 Correct 602 ms 348 KB Output is correct
25 Correct 508 ms 348 KB Output is correct
26 Correct 573 ms 344 KB Output is correct
27 Correct 562 ms 484 KB Output is correct
28 Correct 465 ms 484 KB Output is correct
29 Correct 404 ms 476 KB Output is correct
30 Correct 436 ms 344 KB Output is correct
31 Correct 411 ms 480 KB Output is correct
32 Correct 418 ms 344 KB Output is correct
33 Runtime error 20 ms 12380 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 579 ms 344 KB Output is correct
24 Correct 499 ms 348 KB Output is correct
25 Correct 469 ms 348 KB Output is correct
26 Correct 485 ms 496 KB Output is correct
27 Correct 492 ms 348 KB Output is correct
28 Correct 423 ms 348 KB Output is correct
29 Correct 367 ms 348 KB Output is correct
30 Correct 438 ms 420 KB Output is correct
31 Correct 354 ms 488 KB Output is correct
32 Correct 361 ms 476 KB Output is correct
33 Runtime error 12 ms 10588 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -