Submission #543178

# Submission time Handle Problem Language Result Execution time Memory
543178 2022-03-29T16:27:17 Z status_coding Horses (IOI15_horses) C++14
0 / 100
54 ms 73996 KB
#include "horses.h"
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

struct segS
{
    long long cnt=0, val=0;

    segS operator+(segS b)
    {
        segS ans;

        ans.val = max( val, (cnt * b.val)%mod );
        ans.cnt = (cnt * b.cnt) % mod;

        return ans;
    }
};

int n;
long long x[100005], y[100005];
vector<segS> seg;

void upd(int i, int st, int dr, int p)
{
    if(st == dr)
    {
        seg[p].cnt = x[i];
        seg[p].val = (x[i] * y[i]) % mod;
    }
}

int updateX(int pos, int val)
{
    x[pos]=val;
    upd(pos, 0, n-1, 1);
    return seg[1].val;
}

int updateY(int pos, int val)
{
    y[pos]=val;
    upd(pos, 0, n-1, 1);
    return seg[1].val;
}

int init(int N, int x[], int y[])
{
    n = N;
    seg.resize(4*n+4);

    for(int i=0;i<n;i++)
        upd(i, 0, n-1, 1);

    return seg[1].val;
}

Compilation message

horses.cpp: In function 'int updateX(int, int)':
horses.cpp:39:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   39 |     return seg[1].val;
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:46:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |     return seg[1].val;
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:49:30: warning: declaration of 'y' shadows a global declaration [-Wshadow]
   49 | int init(int N, int x[], int y[])
      |                          ~~~~^~~
horses.cpp:23:22: note: shadowed declaration is here
   23 | long long x[100005], y[100005];
      |                      ^
horses.cpp:49:21: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   49 | int init(int N, int x[], int y[])
      |                 ~~~~^~~
horses.cpp:23:11: note: shadowed declaration is here
   23 | long long x[100005], y[100005];
      |           ^
horses.cpp:57:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   57 |     return seg[1].val;
horses.cpp:49:21: warning: unused parameter 'x' [-Wunused-parameter]
   49 | int init(int N, int x[], int y[])
      |                 ~~~~^~~
horses.cpp:49:30: warning: unused parameter 'y' [-Wunused-parameter]
   49 | int init(int N, int x[], int y[])
      |                          ~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 73996 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -