# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1076691 | beaconmc | 철로 (IOI14_rail) | C++14 | 68 ms | 856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
const ll maxn = 5005;
ll distzero[5005];
ll distone[5005];
bool cmp(ll a, ll b){
return distone[a]<distone[b];
}
bool cmp2(ll a, ll b){
return distzero[a]<distzero[b];
}
void findLocation(int N, int first, int location[], int stype[])
{
ll minval = 1000000000000;
ll one = -1;
location[0] = first;
stype[0] = 1;
FOR(i,1,N){
ll dist = getDistance(i,0);
distzero[i] = dist;
if (dist < minval){
minval = dist;
one = i;
}
}
location[one] = first+minval;
stype[one] = 2;
// cout << "FUCK" << endl;
// cout << minval << endl;
// cout << one << " " << location[one] << " " << endl;
ll fakemini = 1000000000;
FOR(i,1,N){
if (i==one) continue;
distone[i] = getDistance(i,one);
fakemini = min(fakemini, distone[i]);
}
if (fakemini < minval){
ll diff = abs(fakemini- minval);
FOR(i,1,N){
if (abs(distone[i] + diff*2 - distzero[i]) == minval) distone[i] += diff*2;
}
}
vector<ll> lefts, rights;
vector<ll> left2, right2;
FOR(i,1,N){
if (i==one) continue;
// cout << i << " " << distzero[i] << " " << distone[i] << "FUCK" << endl;
if (distzero[i] >= distone[i]) lefts.push_back(i);
else rights.push_back(i);
}
left2 = lefts;
right2 = rights;
// cout << "LMAO" << rights.size() << endl;
sort(lefts.begin(), lefts.end(), cmp);
reverse(lefts.begin(), lefts.end());
while (lefts.size() && distone[lefts[lefts.size()-1]] < minval){
ll temp = lefts[lefts.size()-1];
location[temp] = location[one] - distone[temp];
stype[temp] = 1;
lefts.pop_back();
}
reverse(lefts.begin(), lefts.end());
ll cur;
vector<ll> stuff;
if (lefts.size()){
ll temp = lefts[0];
location[temp] = location[one] - distone[temp];
cur = temp;
stype[temp] = 1;
stuff.push_back(-location[temp]);
}
ll cnt = 0;
FOR(i,1,lefts.size()){
ll temp = lefts[i];
ll dist = getDistance(cur, temp);
ll potential = location[cur] + dist;
ll sus = -(*upper_bound(stuff.begin(), stuff.end(), -potential));
//cout << abs(sus -potential) << " "<< location[one] << " " << sus << " " << distone[temp] << endl;
if ((abs(sus -potential) + location[one] - sus) == distone[temp]){
location[temp] = potential;
stype[temp] = 2;
}
else{
location[temp] = location[one] - distone[temp];
stype[temp] = 1;
cur = temp;
stuff.push_back(-location[temp]);
}
}
stuff.clear();
sort(rights.begin(), rights.end(), cmp2);
if (rights.size()){
ll temp = rights[0];
location[temp] = location[0] + distzero[temp];
cur = rights[0];
stype[temp] = 2;
stuff.push_back(location[temp]);
}
FOR(i,1,rights.size()){
ll temp = rights[i];
ll dist = getDistance(cur, temp);
ll potential = location[cur] - dist;
ll sus = *upper_bound(stuff.begin(), stuff.end(), potential);
if (abs(sus - potential) + sus - location[0] == distzero[temp]){
location[temp] = location[cur] -dist;
stype[temp] = 1;
}
else{
location[temp] = location[0] + distzero[temp];
stype[temp] = 2;
cur = temp;
stuff.push_back(location[temp]);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |