Submission #642484

#TimeUsernameProblemLanguageResultExecution timeMemory
642484Edbert2397Xylophone (JOI18_xylophone)C++14
100 / 100
119 ms468 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; // static int A[5000]; int a[5005],b[5005],c[5005],arr[5005]; void solve(int n) { for(int i = 1;i<n;i++){ a[i] = query(i,i + 1); } for(int i = 3;i<=n;i++){ b[i] = query(i-2,i); } c[1] = a[1]; for(int i = 2;i<n;i++){ c[i] = a[i]; if(c[i-1] < 0){ c[i] = -c[i]; } if(a[i-1] + a[i] != b[i + 1]){ c[i] = -c[i]; } } arr[1] = 0; int mini = 0; for(int i = 2;i<=n;i++){ arr[i] = arr[i-1] + c[i-1]; mini = min(mini,arr[i]); } int l,r; for(int i = 1;i<=n;i++){ arr[i] += (-mini) + 1; if(arr[i] == 1) l = i; if(arr[i] == n) r = i; } if(l > r){ for(int i= 1;i<=n;i++){ arr[i] = n - arr[i] + 1; } } for(int i = 1; i <= n; i++) { answer(i, arr[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:36:5: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     if(l > r){
      |     ^~
xylophone.cpp:36:5: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...