Submission #432663

#TimeUsernameProblemLanguageResultExecution timeMemory
432663daniel920712Horses (IOI15_horses)C++14
34 / 100
31 ms15376 KiB
#include "horses.h"
#include <iostream>
using namespace std;
long long XX[100005];
long long YY[100005];
long long how[100005]={0};
long long MOD=1e9+7;
long long N;
int init(int N, int X[], int Y[])
{
    long long ans=0,t=1,i,now=0;
    ::N=N;
    for(i=0;i<N;i++)
    {
        XX[i]=(long long) X[i];
        YY[i]=(long long) Y[i];
    }
    for(i=N-1;i>=0;i--)
    {
        if(Y[i]>now)
        {
            now=YY[i];
            t=YY[i];
        }
        t*=XX[i];
        t%=MOD;
        if(now<1000000000) now*=XX[i];
    }
	return (int) t;
}

int updateX(int pos, int val)
{
    long long ans=0,t=1,i,now=0;
    XX[pos]=(long long) val;
    for(i=N-1;i>=0;i--)
    {
        if(YY[i]>now)
        {
            now=YY[i];
            t=YY[i];
        }
        t*=XX[i];
        t%=MOD;
        if(now<1000000000) now*=XX[i];
    }
	return (int) t;
}

int updateY(int pos, int val)
{
    long long ans=0,t=1,i,now=0;
    YY[pos]=(long long) val;
    for(i=N-1;i>=0;i--)
    {
        if(YY[i]>now)
        {
            now=YY[i];
            t=YY[i];
        }
        t*=XX[i];
        t%=MOD;
        if(now<1000000000) now*=XX[i];
    }
	return (int) t;
}

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:9:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
    9 | int init(int N, int X[], int Y[])
      |          ~~~~^
horses.cpp:8:11: note: shadowed declaration is here
    8 | long long N;
      |           ^
horses.cpp:11:15: warning: unused variable 'ans' [-Wunused-variable]
   11 |     long long ans=0,t=1,i,now=0;
      |               ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:34:15: warning: unused variable 'ans' [-Wunused-variable]
   34 |     long long ans=0,t=1,i,now=0;
      |               ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:52:15: warning: unused variable 'ans' [-Wunused-variable]
   52 |     long long ans=0,t=1,i,now=0;
      |               ^~~
#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...