Submission #368417

# Submission time Handle Problem Language Result Execution time Memory
368417 2021-02-20T04:13:10 Z RyoPham Xylophone (JOI18_xylophone) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 5005;

int n;
int a[maxn];

int f[maxn], g[maxn];

int b[maxn];

void build_b(int sign)
{
    b[2] = (sign ? 1 : -1) * f[1];
    for(int i = 3; i <= n; ++i)
    {
        if(g[i - 2] != f[i - 2] + f[i - 1])
            sign ^= 1;
        b[i] = b[i - 1] + (sign ? 1 : -1) * f[i - 1];
    }
}

void solve(int N)
{
    n = N;
    if(N == 2)
    {
        answer(1, 1);
        answer(1, 2);
        return;
    }
    for(int i = 1; i < n; ++i)
        f[i] = query(i, i + 1);
    for(int i = 1; i < n - 1; ++i)
        g[i] = query(i, i + 2);
    build_b(1);
    pii mn = pii(0, 1), mx = pii(0, 1);
    for(int i = 2; i <= n; ++i)
    {
        mn = min(mn, pii(b[i], i));
        mx = max(mx, pii(b[i], i));
    }
    if(mn.se > mx.se)
        build_b(0);
    mn = mx = pii(0, 1);
    for(int i = 2; i <= n; ++i)
    {
        mn = min(mn, pii(b[i], i));
        mx = max(mx, pii(b[i], i));
    }
    for(int i = 1; i <= n; ++i)
        answer(i, b[i] - mn.fi + 1);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -