# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
104281 |
2019-04-04T17:15:30 Z |
naoai |
철로 (IOI14_rail) |
C++14 |
|
97 ms |
888 KB |
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 5000;
static int v[nmax + 1];
static int tip[nmax + 1];
int d0[nmax + 1];
pair<int, int> ord[nmax + 1];
set<int> C, D;
bool checkC (int pos, int L, int dL, int ind) {
set<int>::iterator it = D.upper_bound(max(v[0], pos));
if (it == D.end())
return 0;
if (d0[ind] != *it * 2 - v[0] - pos)
return 0;
return 1;
}
bool checkD (int pos, int R, int dR, int ind) {
set<int>::iterator it = C.lower_bound(pos);
if (it == C.begin())
return 0;
-- it;
if (dR != pos + v[R] - 2 * (*it))
return 0;
set<int>::iterator shp = D.upper_bound(v[0]);
if (shp == D.end())
return 0;
return (d0[ind] == (*shp - v[0]) + (pos - *it) + (*shp - *it));
}
bool checkL (int pos, int dr, int dzero) {
set<int>::iterator it = D.lower_bound(v[0]);
if (it == D.end())
return 0;
if (dzero != 2 * (*it) - v[0] - pos)
return 0;
return 1;
}
void findLocation(int N, int first, int location[], int stype[]) {
v[0] = first;
tip[0] = 1;
for (int i = 1; i < N; ++ i) {
int x;
x = getDistance(0, i);
d0[i] = x;
ord[i] = {d0[i], i};
}
sort(ord + 1, ord + N);
int l = 0, r = ord[1].second;
v[r] = v[0] + d0[r];
tip[r] = 2;
C.insert(v[0]);
D.insert(v[r]);
for (int i = 2; i < N; ++ i) {
int c = ord[i].second;
int dl = getDistance(c, l), dr = getDistance(c, r);
if (v[0] < v[r] - dr && checkC(v[r] - dr, l, dl, c)) {
tip[c] = 1;
v[c] = v[r] - dr;
C.insert(v[c]);
} else if (v[l] + dl < v[0] && checkD(v[l] + dl, r, dr, c)){
tip[c] = 2;
v[c] = v[l] + dl;
D.insert(v[c]);
} else if (v[r] - dr < v[l] && checkL(v[r] - dr, dr, d0[c])) {
tip[c] = 1;
v[c] = v[r] - dr;
C.insert(v[c]);
} else {
tip[c] = 2;
v[c] = v[l] + dl;
D.insert(v[c]);
}
if (v[c] > v[r])
r = c;
if (v[c] < v[l])
l = c;
}
for (int i = 0; i < N; ++ i) {
location[i] = v[i];
stype[i] = tip[i];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
74 ms |
752 KB |
Output is correct |
2 |
Correct |
81 ms |
888 KB |
Output is correct |
3 |
Correct |
82 ms |
764 KB |
Output is correct |
4 |
Correct |
86 ms |
888 KB |
Output is correct |
5 |
Correct |
83 ms |
760 KB |
Output is correct |
6 |
Correct |
84 ms |
860 KB |
Output is correct |
7 |
Correct |
75 ms |
800 KB |
Output is correct |
8 |
Correct |
89 ms |
888 KB |
Output is correct |
9 |
Correct |
74 ms |
760 KB |
Output is correct |
10 |
Correct |
77 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
748 KB |
Output is correct |
2 |
Correct |
83 ms |
796 KB |
Output is correct |
3 |
Correct |
81 ms |
860 KB |
Output is correct |
4 |
Correct |
97 ms |
780 KB |
Output is correct |
5 |
Correct |
91 ms |
888 KB |
Output is correct |
6 |
Correct |
79 ms |
860 KB |
Output is correct |
7 |
Correct |
91 ms |
888 KB |
Output is correct |
8 |
Correct |
80 ms |
772 KB |
Output is correct |
9 |
Correct |
72 ms |
768 KB |
Output is correct |
10 |
Correct |
71 ms |
860 KB |
Output is correct |
11 |
Correct |
71 ms |
800 KB |
Output is correct |
12 |
Correct |
73 ms |
888 KB |
Output is correct |
13 |
Correct |
73 ms |
888 KB |
Output is correct |
14 |
Correct |
72 ms |
764 KB |
Output is correct |
15 |
Correct |
70 ms |
888 KB |
Output is correct |
16 |
Correct |
79 ms |
760 KB |
Output is correct |
17 |
Correct |
71 ms |
756 KB |
Output is correct |
18 |
Correct |
71 ms |
764 KB |
Output is correct |
19 |
Correct |
72 ms |
888 KB |
Output is correct |
20 |
Correct |
73 ms |
760 KB |
Output is correct |