이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define F first
#define S second
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
void findLocation(ll n, ll f, ll pos[], ll type[])
{
type[0] = 1;
pos[0] = f;
vii v0;
for (ll i =1; i<n; i++){
v0.pb(ii(getDistance(0,i), i));
}
sort(v0.begin(), v0.end());
ll first_right = v0[0].S;
type[first_right] = 2;
pos[first_right] = f + v0[0].F;
for (ll i =1; i<n; i++){
if (first_right == i) continue;
ll distance_from_zero = getDistance(0, i);
ll distance_from_right = getDistance(first_right, i);
if (distance_from_zero <= v0[0].F * 2){
pos[i] = f + distance_from_zero;
type[i] = 2;
}
else{
ll expected_distance_from_right = distance_from_zero - v0[0].F;
if (expected_distance_from_right == distance_from_right){
pos[i] = f - (distance_from_right - v0[0].F);
type[i] = 1;
}
else{
pos[i] = f + distance_from_zero;
type[i] = 2;
}
}
}
}
/*
1
4
1 1
2 4
2 7
2 9
2
6
1 3
2 6
2 7
1 1
1 0
2 8
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |