Submission #348811

# Submission time Handle Problem Language Result Execution time Memory
348811 2021-01-15T19:22:32 Z Sprdalo Horses (IOI15_horses) C++17
34 / 100
1500 ms 12268 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

const int mod = 1e9 + 7;

void f(ll& x){
    if (x >= mod)
        x %= mod;
}

ll g(ll x){
    f(x);
    return x;
}

vi X, Y;
int N;

int solve(){
    ll sol = 0, maxy = 0, s = 1;
    ll cur = 1;
    for (int i = 0; i < N; ++i){
        s *= X[i];
        cur *= X[i];
        f(cur);

        if (s >= maxy){
            maxy = Y[i];
            sol = g(cur * Y[i]);
            s = 1;
            continue;
        }

        s *= Y[i];
        if (s >= maxy){
            maxy = Y[i];
            sol = g(cur * Y[i]);
            s = 1;
            continue;
        }
        s /= Y[i];
    }

    return sol;
}

int init(int n, int x[], int y[]){
    N = n;
    X = vi(n);
    Y=vi(n);
    for (int i = 0; i < n; ++i){
        X[i]=x[i];
        Y[i] = y[i];
    }

    return solve();
}

int updateX(int pos, int val){
    X[pos] = val;
    return solve();
}

int updateY(int pos, int val){
    Y[pos] = val;
    return solve();
}

int man()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n;
    cin >> n;

    int x[n];
    for (int i = 0; i < n; ++i)
        cin >> x[i];

    int y[n];
    for (int i = 0; i < n; ++i)
        cin >> y[i];

    cout << init(n,x,y) << '\n';

    int m;
    cin >> m;

    for (int i = 0; i < m; ++i){
        int type, pos, val;
        cin >> type >> pos >> val;

        if (type == 1)
            cout << updateX(pos, val) << '\n';
        else
            cout << updateY(pos, val) << '\n';
    }
}

Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:58:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   58 |     return sol;
      |            ^~~
horses.cpp: In function 'int man()':
horses.cpp:115:1: warning: no return statement in function returning non-void [-Wreturn-type]
  115 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 0 ms 364 KB Output is correct
19 Correct 0 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 4 ms 364 KB Output is correct
24 Correct 4 ms 364 KB Output is correct
25 Correct 7 ms 364 KB Output is correct
26 Correct 7 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 7 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 5 ms 364 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1591 ms 8192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 0 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 0 ms 364 KB Output is correct
17 Correct 0 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 0 ms 364 KB Output is correct
21 Correct 0 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 4 ms 364 KB Output is correct
24 Correct 6 ms 364 KB Output is correct
25 Correct 7 ms 364 KB Output is correct
26 Correct 7 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 7 ms 368 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 5 ms 364 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Execution timed out 1584 ms 12268 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 0 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 0 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 8 ms 364 KB Output is correct
24 Correct 4 ms 364 KB Output is correct
25 Correct 8 ms 364 KB Output is correct
26 Correct 7 ms 364 KB Output is correct
27 Correct 3 ms 364 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 5 ms 364 KB Output is correct
31 Correct 2 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Execution timed out 1563 ms 10368 KB Time limit exceeded
34 Halted 0 ms 0 KB -