Submission #348142

#TimeUsernameProblemLanguageResultExecution timeMemory
348142mariowongXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int dif1[5005],dif2[5005],b[5005]; pair <int,int> a[5005]; bool vis[5005]; void solve(int N) { for (int i=2;i<=N;i++){ dif1[i]=query(i-1,i); } for (int i=3;i<=N;i++){ dif2[i]=query(i-2,i); } a[2].first=0; a[2].second=1; for (int i=3;i<=N;i++){ if (dif1[i]+dif1[i-1] == dif2[i]) a[i]=a[i-1]; else { a[i].first=a[i-1].second; a[i].second=a[i-1].first; } } for (int i=1;i<=N;i++){ b[1]=i; for (int j=1;j<=N;j++){ vis[j]=false; } for (int j=2;j<=N;j++){ if (a[j].first == 1) b[j]=b[j-1]+dif1[j]; else b[j]=b[j-1]-dif1[j]; } for (int j=1;j<=N;j++){ if (b[j] == 1) pos1=j; if (b[j] == n) posn=j; if (b[j] < 1 || b[j] > N) break; if (vis[b[j]]) break; vis[b[j]]=true; if (j == N && pos1 < posn) goto out; } for (int j=1;j<=N;j++){ vis[j]=false; } b[1]=i; for (int j=2;j<=N;j++){ if (a[j].second == 1) b[j]=b[j-1]+dif1[j]; else b[j]=b[j-1]-dif1[j]; } for (int j=1;j<=N;j++){ if (b[j] == 1) pos1=j; if (b[j] == n) posn=j; if (b[j] < 1 || b[j] > N) break; if (vis[b[j]]) break; vis[b[j]]=true; if (j == N && pos1 < posn) goto out; } } out:; for(int i = 1; i <= N; i++) { answer(i, b[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:39:4: error: 'pos1' was not declared in this scope
   39 |    pos1=j;
      |    ^~~~
xylophone.cpp:40:16: error: 'n' was not declared in this scope
   40 |    if (b[j] == n)
      |                ^
xylophone.cpp:41:4: error: 'posn' was not declared in this scope
   41 |    posn=j;
      |    ^~~~
xylophone.cpp:47:18: error: 'pos1' was not declared in this scope
   47 |    if (j == N && pos1 < posn)
      |                  ^~~~
xylophone.cpp:47:25: error: 'posn' was not declared in this scope
   47 |    if (j == N && pos1 < posn)
      |                         ^~~~
xylophone.cpp:63:4: error: 'pos1' was not declared in this scope
   63 |    pos1=j;
      |    ^~~~
xylophone.cpp:64:16: error: 'n' was not declared in this scope
   64 |    if (b[j] == n)
      |                ^
xylophone.cpp:65:4: error: 'posn' was not declared in this scope
   65 |    posn=j;
      |    ^~~~
xylophone.cpp:71:18: error: 'pos1' was not declared in this scope
   71 |    if (j == N && pos1 < posn)
      |                  ^~~~
xylophone.cpp:71:25: error: 'posn' was not declared in this scope
   71 |    if (j == N && pos1 < posn)
      |                         ^~~~