답안 #649424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
649424 2022-10-10T07:57:37 Z ToroTN 말 (IOI15_horses) C++14
34 / 100
1500 ms 19912 KB
#include<bits/stdc++.h>
using namespace std;
#include "horses.h"
#define ll long long
ll n,x[500005],y[500005],z[500005],node,ans,md=1000000007;
int init(int N, int X[], int Y[]) {
	n=N;
	for(int i=1;i<=n;i++)
	{
		x[i]=X[i-1];
		y[i]=Y[i-1];
	}
	node=n;
	z[n]=y[n];
	for(int i=n-1;i>=1;i--)
	{
		if(x[i+1]>1e9||z[i+1]>1e9)
		{
			z[i]=1e18;
		}else
		{
			if(z[i+1]*x[i+1]<y[i])
			{
				node=i;
				z[i]=y[i];
			}else
			{
				z[i]=z[i+1]*x[i+1];
			}
		}
	}
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
	}
	ans*=y[node];
	ans%=md;
	return ans;
}

int updateX(int pos, int val) {
	pos+=1;
	x[pos]=val;
	z[n]=y[n];
	node=n;
	for(int i=n-1;i>=1;i--)
	{
		if(x[i+1]>1e9||z[i+1]>1e9)
		{
			z[i]=1e18;
		}else
		{
			if(z[i+1]*x[i+1]<y[i])
			{
				node=i;
				z[i]=y[i];
			}else
			{
				z[i]=z[i+1]*x[i+1];
			}
		}
	}
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
	}
	ans*=y[node];
	ans%=md;
	return ans;
}

int updateY(int pos, int val) {
	pos+=1;
	y[pos]=val;
	z[n]=y[n];
	node=n;
	for(int i=n-1;i>=1;i--)
	{
		if(x[i+1]>1e9||z[i+1]>1e9)
		{
			z[i]=1e18;
		}else
		{
			if(z[i+1]*x[i+1]<y[i])
			{
				node=i;
				z[i]=y[i];
			}else
			{
				z[i]=z[i+1]*x[i+1];
			}
		}
	}
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
	}
	ans*=y[node];
	ans%=md;
	return ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:15:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   15 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:17:11: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   17 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |      ~~~~~^
horses.cpp:17:23: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   17 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |                  ~~~~~^
horses.cpp:40:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   40 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:48:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   48 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:50:11: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   50 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |      ~~~~~^
horses.cpp:50:23: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   50 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |                  ~~~~~^
horses.cpp:73:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   73 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:81:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   81 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:83:11: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   83 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |      ~~~~~^
horses.cpp:83:23: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   83 |   if(x[i+1]>1e9||z[i+1]>1e9)
      |                  ~~~~~^
horses.cpp:106:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  106 |  return ans;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 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 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 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 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 308 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 0 ms 212 KB Output is correct
2 Correct 1 ms 308 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 0 ms 212 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 212 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 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 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 8 ms 380 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 12 ms 340 KB Output is correct
26 Correct 13 ms 380 KB Output is correct
27 Correct 8 ms 320 KB Output is correct
28 Correct 8 ms 320 KB Output is correct
29 Correct 9 ms 340 KB Output is correct
30 Correct 10 ms 320 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 7 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1588 ms 16788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 308 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 340 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
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 7 ms 340 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 12 ms 340 KB Output is correct
26 Correct 12 ms 320 KB Output is correct
27 Correct 8 ms 340 KB Output is correct
28 Correct 7 ms 340 KB Output is correct
29 Correct 9 ms 340 KB Output is correct
30 Correct 12 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 7 ms 384 KB Output is correct
33 Execution timed out 1559 ms 19912 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 8 ms 384 KB Output is correct
24 Correct 7 ms 340 KB Output is correct
25 Correct 11 ms 388 KB Output is correct
26 Correct 12 ms 384 KB Output is correct
27 Correct 8 ms 316 KB Output is correct
28 Correct 8 ms 340 KB Output is correct
29 Correct 10 ms 368 KB Output is correct
30 Correct 11 ms 340 KB Output is correct
31 Correct 5 ms 316 KB Output is correct
32 Correct 8 ms 404 KB Output is correct
33 Execution timed out 1577 ms 18120 KB Time limit exceeded
34 Halted 0 ms 0 KB -