Submission #1175221

#TimeUsernameProblemLanguageResultExecution timeMemory
1175221nguyenkhangninh99Xylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB

#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

void solve(int N){
    int n = N;
    if(n == 2){
        answer(1, 1);
        answer(2, 2);
    }
    else{
        vector<int> diff(n + 1), ans(n + 1);
        for(int i = 1; i < n; i++) diff[i] = query(i, i + 1);
        
        ans[2] = diff[1];
        
        int pos = -1, mn = n + 1, cur = 1;

        for(int i = 3; i <= n; i++){
            if(query(i - 2, i) != diff[i - 1] + diff[i - 2]) cur *= -1;
            ans[i] = ans[i - 1] + diff[i - 1] * cur;
        }
        
        for(int i = 1; i <= n; i++){
            if(ans[i] < mn){
                mn = ans[i];
                pos = i;
            }
        }

        bool ok = 0;
        for(int i = pos + 1; i <= n; i++) ok |= (ans[i] == mn + n - 1);
        if(!ok){
            mn = n + 1;
            for(int i = 1; i <= n; i++) mn = min(mn, -ans[i])
        }
    
        for(int i = 1; i <= n; i++) answer(i, ans[i] - mn + 1);
    }
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:37:62: error: expected ';' before '}' token
   37 |             for(int i = 1; i <= n; i++) mn = min(mn, -ans[i])
      |                                                              ^
      |                                                              ;
   38 |         }
      |         ~