Submission

Status:

Compilation Error

Subtask/Task Score:

Score: 0

User: saganegadih

Problemset: รถไฟตู้เสบียง (Dining Car)

Language: cpp

Time: 0.000 second

Submitted On: 2026-06-01 00:23:15

#include <bits/stdc++.h>
#include "dining_car.h"

using namespace std;

// you can also write additional functions here


pair < int, int > locate_dining_cars(int N) 
{
  //write your code here

  //you can call "compare_cars(i,j)"
  int k;
  int init = compare_cars(1,N);
  int eq[2] = {1,N};
  int num = 0;
  int ori = N;
  while(ori!=0){
      ori = (int)floor(n/2);
      num++;
  }
  num = (int)pow(2,num-2);
  if(init == -1){
      k = N;
      while(num!=0){
        
        k = k + compare_cars(1,k)*num;
        num = (int)floor(num/2);
      }
      
      eq[0] = 1;
      eq[1] = k;
  }
  if(init == 1){
      k = 1;
      while(num!=0){
        k = k + compare_cars(1,k)*num;
        num = (int)floor(num/2);
      }
      
      eq[0] = k;
      eq[1] = N;
  }
  while(compare_cars(eq[0]+1,eq[1])==-1){
      eq[0]++;
      eq[1]--;
  }
  int max,min;
  if(eq[0]>eq[1]){
      max = eq[0];
      min = eq[1];
  }else{
      max = eq[1];
      min = eq[0];
  }

  return make_pair(min, max);
}