제출 #565594

#제출 시각아이디문제언어결과실행 시간메모리
565594RealSnakeXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" void solve(int n) { int l = 1, r = n, j = 1; int a[n + 1]; for(int i = 1; i <= n; i++) { int x = query(i, n); if(x == n - 1) j = i; else break; } a[j] = 1; int b[n + 1]; for(int i = j - 1; i >= 0; i--) { int x = query(i, i + 1); b[i] = x; if(i == j - 1) { a[i] = x + 1; continue; } int y = query(i, i + 2); if(a[i + 1] < a[i + 2]) { if(a[i + 1] + x < a[i + 2]) { if(y == b[i + 1]) a[i] = a[i + 1] + x; else a[i] = a[i + 1] - x; } else { if(y == a[i + 2] - (a[i + 1] - x)) a[i] = a[i + 1] - x; else a[i] = a[i + 1] + x; } } else { if(a[i + 1] - x > a[i + 2]) { if(y == b[i + 1]) a[i] = a[i + 1] - x; else a[i] = a[i + 1] + x; } else { if(y == (a[i + 1] + x) - a[i + 2]) a[i] = a[i + 1] + x; else a[i] = a[i + 1] - x; } } } for(int i = j + 1; i <= n; i++) { int x = query(i - 1, i); b[i] = x; if(i == j + 1) { a[i] = x + 1; continue; } int y = query(i - 2, i); if(a[i - 1] < a[i - 2]) { if(a[i - 1] + x < a[i - 2]) { if(y == b[i - 1]) a[i] = a[i - 1] + x; else a[i] = a[i - 1] - x; } else { if(y == a[i - 2] - (a[i - 1] - x)) a[i] = a[i - 1] - x; else a[i] = a[i - 1] + x; } } else { if(a[i - 1] - x > a[i - 2]) { if(b[i - 1] == y) a[i] = a[i - 1] - x; else a[i] = a[i - 1] + x; } else { if(y == (a[i - 1] + x) - a[i - 2]) a[i] = a[i - 1] + x; else a[i] = a[i - 1] - x; } } } for(int i = 1; i <= n; i++) ans(i, a[i]); }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:91:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   91 |         ans(i, a[i]);
      |         ^~~
      |         abs
xylophone.cpp:5:9: warning: unused variable 'l' [-Wunused-variable]
    5 |     int l = 1, r = n, j = 1;
      |         ^
xylophone.cpp:5:16: warning: unused variable 'r' [-Wunused-variable]
    5 |     int l = 1, r = n, j = 1;
      |                ^