Submission #1018103

# Submission time Handle Problem Language Result Execution time Memory
1018103 2024-07-09T14:22:38 Z tigar Xylophone (JOI18_xylophone) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int ans1[5050], ans2[5050];
int mn2=0, mnp2=1, mn1=0, mnp1=1, mx1=0, mxp1=1, mx2=0, mxp2=1;

/*void answer(int s, int t)
{
    cout<<s<<" "<<t<<endl;
    return;
}

int query(int s, int t)
{
    cout<<s<<" "<<t<<endl;
    int k; cin>>k; return k;
}*/

void solve(int N)
{
    ans1[1]=0; ans2[1]=0;
    ans1[2]=query(1, 2);
    ans2[2]=-ans1[2];
    int hlast=ans1[2];
    for(int i=3; i<=N; i++)
    {
        int h1=query(i-1, i), h2=query(i-2, i);
        if(hlast+h1==h2)
        {
            if(ans1[i-1]>ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]>ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        else
        {
            if(ans1[i-1]<ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]<ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        if(ans1[i]<mn1){mn1=min(mn1, ans1[i]); mnp1=i;}
        if(ans2[i]<mn2){mn2=min(mn2, ans2[i]); mnp2=i;}
        if(ans1[i]>mx1){mx1=max(mx1, ans1[i]); mxp1=i;}
        if(ans2[i]>mx2){mx2=max(mx2, ans2[i]); mxp2=i;}
        hlast=h1;
    }
    if(mxp1>mnp1)
    {
        for(int i=1; i<=N; i++)answer(i, ans1[i]-mn1+2);
    }
    else
    {
        for(int i=1; i<=N; i++)answer(i, ans2[i]-mn2+2);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -