Submission #74328

#TimeUsernameProblemLanguageResultExecution timeMemory
74328Mamnoon_SiamXylophone (JOI18_xylophone)C++17
0 / 100
2 ms376 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int N) { if(N == 2) { answer(0, 0); answer(1, 1); return; } vector<int> a(N), two(N), three(N); for(int i = 0; i < N - 1; i++) { two[i] = query(i + 1, i + 1 + 1); if(i < N - 2) three[i] = query(i + 1, i + 2 + 1); } a[1] = two[0]; int tog = 1; for(int i = 2; i < N; i++) { if(three[i - 2] == two[i - 2] + two[i - 1]) { a[i] = tog ? a[i - 1] + two[i - 1] : a[i - 1] - two[i - 1]; } else { a[i] = tog ? a[i - 1] - two[i - 1] : a[i - 1] + two[i - 1]; tog ^= 1; } } int mxid, mnid, mx = -1e5, mn = 1e5; for(int i = 0; i < N; i++) { if(a[i] < mn) mn = a[i], mnid = i; if(a[i] > mx) mx = a[i], mxid = i; } if(mxid < mnid) { for(int &b : a) b = -b; swap(mn, mx); mx = -mx, mn = -mn; } for(int i = 0; i < N; i++) a[i] -= mn; for(int i = 0; i < N; i++) answer(i + 1, a[i] + 1); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:31:2: warning: 'mxid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if(mxid < mnid) {
  ^~
xylophone.cpp:31:2: warning: 'mnid' 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...