Submission #996129

#TimeUsernameProblemLanguageResultExecution timeMemory
996129reginoxXylophone (JOI18_xylophone)C++17
Compilation error
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 try(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(try(v1, v1+z)){ for(int i = 1; i <= n; i++) answer(i, a[i]); return ; } } } }

Compilation message (stderr)

xylophone.cpp:11:6: error: expected unqualified-id before 'try'
   11 | bool try(int u, int v){
      |      ^~~
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++){
      |                              ^
xylophone.cpp:54:16: error: expected primary-expression before 'try'
   54 |             if(try(v1, v1+z)){
      |                ^~~
xylophone.cpp:54:16: error: expected ')' before 'try'
   54 |             if(try(v1, v1+z)){
      |               ~^~~
      |                )