Submission #219457

#TimeUsernameProblemLanguageResultExecution timeMemory
219457MKopchevXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
const int nmax=5e3+42;

int output[nmax];
int n;
bool seen[nmax];

int diff[nmax],diff_2[nmax];
/*
int ask(int s,int t)
{
    cout<<s<<" "<<t<<endl;
    int ret;
    cin>>ret;
    return ret;
}

int answer(int s,int t)
{
    cout<<"answer "<<s<<" "<<t<<endl;

}
*/
int my_ask(int s,int t)
{
    return ask(s,t);
}

int maxi(vector<int> now)
{
    int a=0;
    for(auto k:now)
        a=max(a,k);
    return a;
}
int mini(vector<int> now)
{
    int a=nmax;
    for(auto k:now)
        a=min(a,k);
    return a;
}

void print()
{
    for(int i=1;i<=n;i++)
        answer(i,output[i]);
    exit(0);
}

void rec(int val,int pos)
{
    if(1>val||val>n)return;
    if(seen[val])return;

    seen[val]=1;
    output[pos]=val;

    if(diff_2[pos])
    {
        if(maxi({output[pos-2],output[pos-1],output[pos]})-mini({output[pos-2],output[pos-1],output[pos]})!=diff_2[pos])return;
    }

    if(pos==n)print();

    rec(val+diff[pos],pos+1);

    rec(val-diff[pos],pos+1);

    seen[val]=0;
}
void detect_pitch(int N)
{
    n=N;

    for(int i=1;i+1<=n;i++)
        diff[i]=ask(i,i+1);

    for(int i=3;i<=n;i++)
        diff_2[i]=ask(i-2,i);

    for(int i=1;i<=n;i++)
        rec(i,1);
}
/*
int main()
{
    detect_pitch(5);
}
*/

Compilation message (stderr)

xylophone.cpp: In function 'int my_ask(int, int)':
xylophone.cpp:28:12: error: 'ask' was not declared in this scope
     return ask(s,t);
            ^~~
xylophone.cpp: In function 'void detect_pitch(int)':
xylophone.cpp:79:17: error: 'ask' was not declared in this scope
         diff[i]=ask(i,i+1);
                 ^~~
xylophone.cpp:82:19: error: 'ask' was not declared in this scope
         diff_2[i]=ask(i-2,i);
                   ^~~