Submission #111251

# Submission time Handle Problem Language Result Execution time Memory
111251 2019-05-14T13:31:45 Z aleksami Xylophone (JOI18_xylophone) C++14
0 / 100
3 ms 384 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

void solve(int n)
{
  int a[n+1];
  int l = 1;
  int r = n;
  bool moze_desno=true;
  bool moze_levo=true;
  while(1)
  {
    if(r-l==2)break;
    if(moze_desno)
    {
      if(query(l,r-1)==n-1)
      {
        r--;
        continue;
      }
      else 
      {
        moze_desno=false;
        continue;
      }
    }
    else if(moze_levo)
    {
      if(query(l+1,r)==n-1)
      {
        l++;
        continue;
      }
      else 
      {
        moze_levo=false;
        continue;
      }
    }
    else break;
  }
  a[l]=1;
  a[r]=n;
  for(int i = l-1; i >= 1; i--)
  {
    a[i]=abs(query(i,i+1)-a[i+1]);
  }
  for(int i = l+1; i < r; i++)
  {
    a[i]=abs(query(i,i-1)-a[i-1]);
  }
  for(int i = r+1; i <= n; i++)
  {
    a[i]=abs(query(i,i-1)-a[i-1]);
  }
  for(int i = 1; i <= n; i++)
  {
    answer(i,a[i]);
  }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -