Submission #996108

#TimeUsernameProblemLanguageResultExecution timeMemory
996108vjudge1Xylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long void solve(int n){ if(n==1){ answer(1,1); } else if(n==2){ answer(1,1); answer(1,2); } else{ int diff2[n+1]; int diff1[n+1]; for(int i=3;i<=n;i++){ diff1[i]=query(i-1,i); diff2[i]=query(i-2,i); } int a[n+1]; int dist=query(1,2); for(int m=-1;m<=1;m+=2){ a[1]=1e9; a[2]=a[1]+m*dist; int Min=min(a[1],a[2]); for(int i=3;i<=n;i++){ if(diff2[i]==diff1[i]+abs(a[i-2]-a[i-1])){ if(a[i-2]>a[i-1]){ a[i]=a[i-1]-diff1[i]; } else{ a[i]=a[i-1]+diff1[i]; } } else{ if(a[i-2]>a[i-1]){ a[i]=a[i-1]+diff1[i]; } else{ a[i]=a[i-1]-diff1[i]; } } Min=min(a[1],a[i]); } Min--; bool mark[n+1]={false}; bool flag=true; for(int i=1;i<=n;i++){ a[i]-=Min; if(a[i]>n||a[i]<=1||mark[a[i]]){ flag=false; break; } mark[a[i]]=true; } if(flag){ for(int i=1;i<=n;i++){ answer(i,a[i]); } } } } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:6:8: error: 'answer' was not declared in this scope
    6 |        answer(1,1);
      |        ^~~~~~
xylophone.cpp:9:9: error: 'answer' was not declared in this scope
    9 |         answer(1,1);
      |         ^~~~~~
xylophone.cpp:16:22: error: 'query' was not declared in this scope
   16 |             diff1[i]=query(i-1,i);
      |                      ^~~~~
xylophone.cpp:20:18: error: 'query' was not declared in this scope
   20 |         int dist=query(1,2);
      |                  ^~~~~
xylophone.cpp:57:21: error: 'answer' was not declared in this scope
   57 |                     answer(i,a[i]);
      |                     ^~~~~~