# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
120254 |
2019-06-24T05:50:55 Z |
윤교준(#2950) |
통행료 (IOI18_highway) |
C++14 |
|
411 ms |
36892 KB |
#include "highway.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 90055;
const int MAXM = 130055;
vector<int> G[MAXN];
int A[MAXM], B[MAXM];
vector<int> TL[MAXN], TR[MAXN];
int TLN, TRN;
int DL[MAXN], DR[MAXN];
int N, M, CA, CB;
int L, EI, TLI, TRI;
int Sidx, Eidx;
map<vector<int>, ll> QMP;
inline ll getAns(vector<int> V) {
vector<int> T(M, 0);
for(int v : V) T[v] = 1;
auto it = QMP.find(T);
if(QMP.end() != it)
return it->second;
ll ret = ask(T);
QMP[T] = ret;
return ret;
}
void getOneEdge() {
int s = 0, e = M-1; for(int m; s < e;) {
m = (s+e) >> 1;
vector<int> V;
for(int i = 0; i <= m; i++) V.eb(i);
ll t = getAns(V);
if(t == ll(CA) * L) s = m+1;
else e = m;
}
EI = s;
}
void doBFS(int d[], int sv) {
fill(d, d+N, INF);
d[sv] = 0;
queue<int> PQ; PQ.push(sv);
for(int idx, dst; !PQ.empty(); PQ.pop()) {
idx = PQ.front(); dst = d[idx] + 1;
for(int e : G[idx]) {
int v = A[e] ^ B[e] ^ idx;
if(d[v] <= dst) continue;
d[v] = dst;
PQ.push(v);
}
}
}
void getTL() {
int s = 0, e = TLN; for(int m; s < e;) {
m = (s+e+1) >> 1;
vector<int> V;
for(int i = m; i <= TLN; i++) {
for(int v : TL[i]) {
for(int e : G[v])
V.eb(e);
}
}
ll t = getAns(V);
if(t == ll(CA) * L) e = m-1;
else s = m;
}
TLI = s;
}
int getIdx(vector<int> V) {
int n = sz(V), s = 0, e = n-1; for(int m; s < e;) {
m = (s+e) >> 1;
vector<int> E;
for(int i = 0; i <= m; i++) {
int v = V[i];
for(int e : G[v])
E.eb(e);
}
ll t = getAns(E);
if(t == ll(CA) * L) s = m+1;
else e = m;
}
return V[s];
}
void process() {
for(int i = 0; i < M; i++)
if(A[i] > B[i]) swap(A[i], B[i]);
for(int i = 0; i < M; i++) {
G[A[i]].eb(i);
G[B[i]].eb(i);
}
L = getAns(vector<int>()) / CA;
getOneEdge();
doBFS(DL, A[EI]);
doBFS(DR, B[EI]);
for(int i = 0; i < N; i++) {
if(DL[i] < DR[i]) {
TL[DL[i]].eb(i);
upmax(TLN, DL[i]);
}
if(DL[i] > DR[i]) {
TR[DR[i]].eb(i);
upmax(TRN, DR[i]);
}
}
getTL();
TRI = L - TLI - 1;
Sidx = getIdx(TL[TLI]);
Eidx = getIdx(TR[TRI]);
answer(Sidx, Eidx);
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
::N = N;
::M = sz(U);
::CA = A;
::CB = B;
for(int i = 0; i < M; i++) {
::A[i] = U[i];
::B[i] = V[i];
}
process();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
6568 KB |
Output is correct |
2 |
Correct |
10 ms |
6648 KB |
Output is correct |
3 |
Correct |
8 ms |
6764 KB |
Output is correct |
4 |
Correct |
8 ms |
6612 KB |
Output is correct |
5 |
Correct |
7 ms |
6648 KB |
Output is correct |
6 |
Correct |
8 ms |
6696 KB |
Output is correct |
7 |
Correct |
7 ms |
6684 KB |
Output is correct |
8 |
Correct |
8 ms |
6648 KB |
Output is correct |
9 |
Correct |
8 ms |
6648 KB |
Output is correct |
10 |
Correct |
8 ms |
6688 KB |
Output is correct |
11 |
Correct |
8 ms |
6696 KB |
Output is correct |
12 |
Correct |
10 ms |
6796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6776 KB |
Output is correct |
2 |
Correct |
30 ms |
8752 KB |
Output is correct |
3 |
Correct |
210 ms |
27608 KB |
Output is correct |
4 |
Correct |
220 ms |
29300 KB |
Output is correct |
5 |
Correct |
214 ms |
29080 KB |
Output is correct |
6 |
Correct |
184 ms |
24132 KB |
Output is correct |
7 |
Correct |
240 ms |
29368 KB |
Output is correct |
8 |
Correct |
196 ms |
27288 KB |
Output is correct |
9 |
Correct |
244 ms |
26600 KB |
Output is correct |
10 |
Correct |
220 ms |
26296 KB |
Output is correct |
11 |
Correct |
262 ms |
25428 KB |
Output is correct |
12 |
Correct |
245 ms |
26780 KB |
Output is correct |
13 |
Correct |
227 ms |
25260 KB |
Output is correct |
14 |
Correct |
310 ms |
26260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
8500 KB |
Output is correct |
2 |
Correct |
49 ms |
10600 KB |
Output is correct |
3 |
Correct |
77 ms |
14072 KB |
Output is correct |
4 |
Correct |
208 ms |
29972 KB |
Output is correct |
5 |
Correct |
194 ms |
28212 KB |
Output is correct |
6 |
Correct |
184 ms |
26932 KB |
Output is correct |
7 |
Correct |
281 ms |
28572 KB |
Output is correct |
8 |
Correct |
191 ms |
27268 KB |
Output is correct |
9 |
Correct |
222 ms |
29272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
6744 KB |
Output is correct |
2 |
Correct |
29 ms |
8792 KB |
Output is correct |
3 |
Correct |
168 ms |
19864 KB |
Output is correct |
4 |
Correct |
246 ms |
25528 KB |
Output is correct |
5 |
Correct |
229 ms |
23756 KB |
Output is correct |
6 |
Correct |
240 ms |
24108 KB |
Output is correct |
7 |
Correct |
221 ms |
23288 KB |
Output is correct |
8 |
Correct |
235 ms |
24048 KB |
Output is correct |
9 |
Correct |
254 ms |
29032 KB |
Output is correct |
10 |
Correct |
226 ms |
28688 KB |
Output is correct |
11 |
Correct |
233 ms |
24920 KB |
Output is correct |
12 |
Correct |
216 ms |
25180 KB |
Output is correct |
13 |
Correct |
312 ms |
26580 KB |
Output is correct |
14 |
Correct |
301 ms |
26912 KB |
Output is correct |
15 |
Correct |
227 ms |
22004 KB |
Output is correct |
16 |
Correct |
194 ms |
19972 KB |
Output is correct |
17 |
Correct |
226 ms |
26116 KB |
Output is correct |
18 |
Correct |
289 ms |
27412 KB |
Output is correct |
19 |
Correct |
225 ms |
23632 KB |
Output is correct |
20 |
Correct |
235 ms |
25552 KB |
Output is correct |
21 |
Correct |
184 ms |
26880 KB |
Output is correct |
22 |
Correct |
247 ms |
27168 KB |
Output is correct |
23 |
Correct |
268 ms |
34284 KB |
Output is correct |
24 |
Incorrect |
306 ms |
36256 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
8728 KB |
Output is correct |
2 |
Correct |
34 ms |
8888 KB |
Output is correct |
3 |
Correct |
246 ms |
28468 KB |
Output is correct |
4 |
Correct |
281 ms |
30220 KB |
Output is correct |
5 |
Correct |
294 ms |
36348 KB |
Output is correct |
6 |
Correct |
319 ms |
36892 KB |
Output is correct |
7 |
Correct |
283 ms |
34268 KB |
Output is correct |
8 |
Correct |
311 ms |
31732 KB |
Output is correct |
9 |
Correct |
268 ms |
23492 KB |
Output is correct |
10 |
Correct |
277 ms |
24164 KB |
Output is correct |
11 |
Correct |
296 ms |
32264 KB |
Output is correct |
12 |
Correct |
321 ms |
32296 KB |
Output is correct |
13 |
Correct |
267 ms |
34036 KB |
Output is correct |
14 |
Correct |
326 ms |
33128 KB |
Output is correct |
15 |
Correct |
322 ms |
33660 KB |
Output is correct |
16 |
Correct |
304 ms |
31200 KB |
Output is correct |
17 |
Correct |
214 ms |
31772 KB |
Output is correct |
18 |
Correct |
268 ms |
31536 KB |
Output is correct |
19 |
Correct |
258 ms |
31892 KB |
Output is correct |
20 |
Correct |
259 ms |
32780 KB |
Output is correct |
21 |
Correct |
411 ms |
35228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
8924 KB |
Output is correct |
2 |
Correct |
35 ms |
8808 KB |
Output is correct |
3 |
Correct |
270 ms |
30036 KB |
Output is correct |
4 |
Correct |
297 ms |
29364 KB |
Output is correct |
5 |
Correct |
245 ms |
31660 KB |
Output is correct |
6 |
Correct |
346 ms |
32788 KB |
Output is correct |
7 |
Correct |
275 ms |
29248 KB |
Output is correct |
8 |
Correct |
245 ms |
29752 KB |
Output is correct |
9 |
Correct |
293 ms |
30240 KB |
Output is correct |
10 |
Correct |
318 ms |
34004 KB |
Output is correct |
11 |
Correct |
327 ms |
33348 KB |
Output is correct |
12 |
Correct |
332 ms |
33772 KB |
Output is correct |
13 |
Correct |
284 ms |
26720 KB |
Output is correct |
14 |
Correct |
250 ms |
24012 KB |
Output is correct |
15 |
Correct |
262 ms |
23432 KB |
Output is correct |
16 |
Correct |
241 ms |
24088 KB |
Output is correct |
17 |
Correct |
311 ms |
31684 KB |
Output is correct |
18 |
Correct |
264 ms |
30680 KB |
Output is correct |
19 |
Correct |
282 ms |
32748 KB |
Output is correct |
20 |
Correct |
285 ms |
32024 KB |
Output is correct |
21 |
Correct |
312 ms |
35144 KB |
Output is correct |
22 |
Correct |
330 ms |
33648 KB |
Output is correct |
23 |
Correct |
275 ms |
36296 KB |
Output is correct |
24 |
Correct |
325 ms |
33672 KB |
Output is correct |
25 |
Correct |
311 ms |
32744 KB |
Output is correct |
26 |
Correct |
285 ms |
33136 KB |
Output is correct |
27 |
Partially correct |
254 ms |
33304 KB |
Output is partially correct |
28 |
Correct |
231 ms |
31612 KB |
Output is correct |
29 |
Correct |
239 ms |
29240 KB |
Output is correct |
30 |
Correct |
223 ms |
26884 KB |
Output is correct |
31 |
Partially correct |
238 ms |
32276 KB |
Output is partially correct |
32 |
Correct |
244 ms |
31540 KB |
Output is correct |
33 |
Correct |
234 ms |
31572 KB |
Output is correct |
34 |
Partially correct |
258 ms |
32712 KB |
Output is partially correct |
35 |
Correct |
217 ms |
31620 KB |
Output is correct |
36 |
Incorrect |
268 ms |
32876 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |