#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int niz[5005];
int simuliraj(int a, int b, int c){
return max(max(a,b), c) - min(min(a,b), c);
}
void solve(int N){
n = N;
int poz1 = 0;
int l = 1;
int r = n;
while(l < r){
int mid = (l + r + 1) / 2;
int pom = query(mid, n);
if(pom == n - 1){
l = mid;
}
else
r = mid - 1;
}
poz1 = l;
niz[poz1] = 1;
if(poz1>1){
niz[poz1 - 1] = 1 + query(poz1 - 1, poz1);
}
niz[poz1 + 1] = 1 + query(poz1, poz1 + 1);
for(int i=poz1 - 2; i >= 1; i--){
int val1 = query(i,i+1);
int val2 = query(i,i+2);
int prvi = niz[i + 1] - val1;
int drugi = niz[i + 1] + val1;
if(prvi <= 0 || drugi > n){
if(prvi <= 0)niz[i] = drugi;
else niz[i] = prvi;
continue;
}
int tmp1 = simuliraj(niz[i + 1], niz[i + 2], prvi);
int tmp2 = simuliraj(niz[i + 1], niz[i + 2], drugi);
if(tmp1 == val2)niz[i] = prvi;
else niz[i] = drugi;
}
for(int i=poz1+2; i<=n; i++){
int val1 = query(i-1,i);
int val2 = query(i-2,i);
int prvi = niz[i - 1] - val1;
int drugi = niz[i - 1] + val1;
if(prvi <= 0 || drugi > n){
if(prvi <= 0)niz[i] = drugi;
else niz[i] = prvi;
continue;
}
int tmp1 = simuliraj(niz[i - 1], niz[i - 2], prvi);
int tmp2 = simuliraj(niz[i - 1], niz[i - 2], drugi);
if(tmp1 == val2)niz[i] = prvi;
else niz[i] = drugi;
}
for(int i=1; i<=n; i++)answer(niz[i], i);
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:41:13: warning: unused variable 'tmp2' [-Wunused-variable]
int tmp2 = simuliraj(niz[i + 1], niz[i + 2], drugi);
^~~~
xylophone.cpp:56:13: warning: unused variable 'tmp2' [-Wunused-variable]
int tmp2 = simuliraj(niz[i - 1], niz[i - 2], drugi);
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Incorrect |
3 ms |
248 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |