제출 #996132

#제출 시각아이디문제언어결과실행 시간메모리
996132reginoxXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "xylophone.h" #define ll long long #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> using namespace std; int a[5005]; int p1[5005], p2[5005]; bool thu(int u, int v){ if(v < 1 || v > n) return ; a[1] = u, a[2] = v; for(int i = 3; i <= n; i++){ int d1 = p1[i], d2 = p2[i], d3 = abs(a[i-2] - a[i-1]); if(a[i-2] > a[i-1]){ if(d3 + d1 == d2){ a[i] = a[i-1] - d1; } else if(d2 == d3){ a[i] = a[i-1] + d1; } else{ a[i] = a[i-1] + d2; } } else{ if(d1 == d2){ a[i] = a[i-1] - d1; } else if(d3 == d2){ a[i] = a[i-1] + d1; } else{ a[i] = a[i-1] + d2; } } } vector<bool> ch(n, false); for(int i = 1; i <= n; i++){ if(ch[a[i]-1]) return false; ch[a[i]-1] = true; } return true; } void solve(int n){ int d = query(1, 2); for(int i = 3; i <= n; i++){ p1[i] = query(i-1, i), p2[i] = query(i-2, i); } for(int v1 = 1; v1 <= n; i++){ for(int z = -d; z <= d; z+=2*d){ if(thu(v1, v1+z)){ for(int i = 1; i <= n; i++) answer(i, a[i]); return ; } } } }

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

xylophone.cpp: In function 'bool thu(int, int)':
xylophone.cpp:12:21: error: 'n' was not declared in this scope
   12 |     if(v < 1 || v > n) return ;
      |                     ^
xylophone.cpp:12:24: error: return-statement with no value, in function returning 'bool' [-fpermissive]
   12 |     if(v < 1 || v > n) return ;
      |                        ^~~~~~
xylophone.cpp:14:25: error: 'n' was not declared in this scope
   14 |     for(int i = 3; i <= n; i++){
      |                         ^
xylophone.cpp:39:21: error: 'n' was not declared in this scope
   39 |     vector<bool> ch(n, false);
      |                     ^
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:52:30: error: 'i' was not declared in this scope
   52 |     for(int v1 = 1; v1 <= n; i++){
      |                              ^