Submission #62283

# Submission time Handle Problem Language Result Execution time Memory
62283 2018-07-28T02:27:59 Z Tenuun Horses (IOI15_horses) C++17
0 / 100
49 ms 14432 KB
#include "horses.h"
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;

int n, nxt[500001], prv[500001];
ll now=1;
vector<int>x, y, a;

void pre(){
	int last=-1;
	a.push_back(0);
	for(int i=0; i<n; i++){
		prv[i]=last;
		if(i && x[i]>1){
			last=i;
			a.push_back(i);
		}
	}
	last=n;
	for(int i=n-1; i>=0; i--){
		nxt[i]=last;
		if(x[i]>1) last=i;
	}
	for(int i=0; i<a.size(); i++){
		now*=x[a[i]];
		now%=mod;
	}
}

ll rmq(int l, int r){
	ll ans=0;
	for(int i=l; i<=r; i++){
		ans=max(ans, (ll)y[i]);
	}
	return ans;
}

ll find(){
	int last=a.size()-1, ind=a.size();
	ll ans=1;
	ll now=rmq(a[last], nxt[a[last]]-1);
	for(int i=a.size()-1; i>=0 && now<mod; i--){
		if(now*x[a[i]]>mod) break;
		now*=x[a[i]];
		ind=i;
	}
	ans=now;
	for(int i=a.size()-2; i>=ind; i--){
		now/=x[a[i+1]];
		ans=max(ans, now*rmq(a[i], nxt[a[i]]-1));
	}
	for(int i=ind-1; i>=0; i--){
		ans*=x[i];
		ans%=mod;
	}
	return ans;
}

int init(int N, int X[], int Y[]) {
	n=N;
	for(int i=0; i<n; i++) {x.push_back(X[i]); y.push_back(Y[i]);}
	pre();
	return find();
}

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

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


Compilation message

horses.cpp: In function 'void pre()':
horses.cpp:26:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<a.size(); i++){
               ~^~~~~~~~~
horses.cpp: In function 'long long int find()':
horses.cpp:41:19: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  int last=a.size()-1, ind=a.size();
           ~~~~~~~~^~
horses.cpp:41:33: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  int last=a.size()-1, ind=a.size();
                           ~~~~~~^~
horses.cpp:43:5: warning: declaration of 'now' shadows a global declaration [-Wshadow]
  ll now=rmq(a[last], nxt[a[last]]-1);
     ^~~
horses.cpp:8:4: note: shadowed declaration is here
 ll now=1;
    ^~~
horses.cpp:44:20: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  for(int i=a.size()-1; i>=0 && now<mod; i--){
            ~~~~~~~~^~
horses.cpp:50:20: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  for(int i=a.size()-2; i>=ind; i--){
            ~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:65:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return find();
         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:68:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateX(int pos, int val) { 
                 ^~~
horses.cpp:68:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateX(int pos, int val) { 
                          ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:72:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateY(int pos, int val) {
                 ^~~
horses.cpp:72:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateY(int pos, int val) {
                          ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 432 KB Output is correct
2 Incorrect 2 ms 636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 14432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14432 KB Output is correct
2 Incorrect 3 ms 14432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14432 KB Output is correct
2 Incorrect 3 ms 14432 KB Output isn't correct
3 Halted 0 ms 0 KB -