#include "xylophone.h"
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("snowcow.in","r",stdin)
#define OUTP freopen("snowcow.out","w",stdout)
using namespace std;
void check(vector<int>& signSwap, vector<int>& diff, int sign){
int now = sign * diff[0];
int one = 0;
int mn = min(0, now);
if(now < 0){
one = 1;
}
for(int i = 0; i < (int)signSwap.size();i++){
if(signSwap[i])sign = -sign;
now+=sign * diff[i + 1];
if(now < mn){
mn = now;
one = i + 2;
}
}
vector<int> ans;
int ansSize = diff.size() + 1;
ans.resize(ansSize);
ans[one] = 1;
sign = -1;
for(int i = one + 1;i < ansSize; i++){
if(signSwap[i - 2])sign = -sign;
ans[i] = ans[i - 1] + diff[i - 1] * sign;
if(ans[i] > ansSize || ans[i] <= 0){
return;
}
}
sign = -1;
for(int i = one - 1;i >= 0; i--){
if(signSwap[i])sign = -sign;
ans[i] = ans[i + 1] + diff[i] * sign;
if(ans[i] > ansSize || ans[i] <= 0 || ans[i] == ansSize){
return;
}
}
for(int i = 0 ; i < (int)ans.size();i++){
answer(i + 1, ans[i]);
}
}
void solve(int n){
vector<int> two;
vector<int> three;
if(n == 2){
answer(1, 1);
answer(2, 2);
return;
}
if(n == 3)assert(0);
for(int l = 1; l <n;l++){
two.push_back(query(l, l + 1));
if(l + 2 <= n)three.push_back(query(l, l + 2));
}
vector<int> signSwap;
for(int i = 0; i < (int)two.size() - 1;i++){
if(two[i] + two[i + 1] == three[i]){
signSwap.push_back(0);
}else{
signSwap.push_back(1);
}
}
check(signSwap, two, -1);
check(signSwap, two, 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |