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 11:43:23

#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-2;
	while(ori!=0) {
		ori = (int)floor(ori/2);
		num++;
	}
	num = (int)pow(2,num-1);
    if(N<=50){
    	if(init == -1) {
    		k = N;
    		while(compare_cars(1,k)!=0) {
    			k--;
    		}
    
    		eq[0] = 1;
    		eq[1] = k;
    	}
    	if(init == 1) {
    		k = 1;
    		while(compare_cars(k,N)!=0) {
    			k++;
    		}
    
    		eq[0] = k;
    		eq[1] = N;
    	}
    	while(compare_cars(eq[0]+1,eq[1])==-1) {
    		eq[0]++;
    		eq[1]--;
    	}
    	
    }else{
        eq[0] = 1;
        eq[1] = 2;
        while(compare_cars(eq[0]+1,eq[0])!=0){
            eq[0] += num;
            eq[1] += num;
            num = (int)floor(num/2);
        }
    }
    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);
}