# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125371 |
2019-07-05T07:08:45 Z |
박상수(#3065) |
Park (JOI17_park) |
C++14 |
|
381 ms |
2040 KB |
#include "park.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;
static int Place[1400];
vector <int> E[1410];
int chk[1410];
void Ans(int x, int y) {
if(x > y) swap(x, y);
E[x].pb(y); E[y].pb(x);
Answer(x, y);
}
vector <int> get_q() {
vector <int> q;
bitset <1410> vis; vis.reset();
vis[0] = 1; q.pb(0);
rep(i, szz(q)) {
int t = q[i];
for(int e : E[t]) if(vis[e] == 0) {
vis[e] = 1;
q.pb(e);
}
}
return q;
}
int N;
int Make(int r1, int r2, vector <int> &a) {
memset(Place, 0, sizeof Place);
for(int e : a) {
Place[e] = 1;
}
if(r1 > r2) swap(r1, r2);
Place[r1] = Place[r2] = 1;
if(r1 == 0) {
for(int i=0;i<N;i++) if(chk[i] == 1) Place[i] = 1;
}
return Ask(r1, r2, Place);
}
void add_edge(int x, int y) {
if(x != 0) Ans(x, y);
else {
vector <int> q = get_q();
int m = szz(q);
int low = 1, high = m, res = -1;
while(low <= high) {
int mid = (low + high) >> 1;
memset(Place, 0, sizeof Place);
rep(i, mid) Place[q[i]] = 1;
Place[y] = 1;
int v = Ask(0, y, Place);
if(v) {
res = mid; high = mid - 1;
}
else {
low = mid + 1;
}
}
Ans(q[res-1], y);
}
}
void Do(int a, int b) {
bitset <1410> can; can.set();
rep(i, N) if(chk[i]) can[i] = 0;
can[a] = can[b] = 0;
vector <int> rr;
rep(i, N) if(can[i]) rr.pb(i);
int m = szz(rr);
int low = 0, high = m - 1, res = m;
while(low <= high) {
int mid = (low + high) >> 1;
vector <int> tt;
rep(i, mid) tt.pb(rr[i]);
int v = Make(a, b, tt);
if(v) {
res = mid;
high = mid - 1;
}
else {
low = mid + 1;
}
}
if(res == 0) {
add_edge(a, b);
}
else {
int v = rr[res - 1];
Do(a, v);
Do(v, b);
}
chk[b] = 1;
}
void Detect(int T, int N) {
::N = N;
if(T == 1) {
for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) {
memset(Place, 0, sizeof Place);
Place[i] = Place[j] = 1;
int v = Ask(i, j, Place);
if(v) Ans(i, j);
}
}
else if(T <= 4) {
chk[0] = 1;
for(int i=1;i<N;i++) if(chk[i] == 0) {
Do(0, i);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
376 KB |
Output is correct |
3 |
Correct |
11 ms |
376 KB |
Output is correct |
4 |
Correct |
11 ms |
376 KB |
Output is correct |
5 |
Correct |
11 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
688 KB |
Output is correct |
2 |
Correct |
243 ms |
668 KB |
Output is correct |
3 |
Correct |
196 ms |
2040 KB |
Output is correct |
4 |
Correct |
111 ms |
632 KB |
Output is correct |
5 |
Correct |
112 ms |
732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
323 ms |
560 KB |
Output is correct |
2 |
Correct |
354 ms |
504 KB |
Output is correct |
3 |
Correct |
381 ms |
580 KB |
Output is correct |
4 |
Correct |
317 ms |
552 KB |
Output is correct |
5 |
Correct |
360 ms |
504 KB |
Output is correct |
6 |
Correct |
345 ms |
504 KB |
Output is correct |
7 |
Correct |
345 ms |
604 KB |
Output is correct |
8 |
Correct |
356 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
632 KB |
Output is correct |
2 |
Correct |
333 ms |
760 KB |
Output is correct |
3 |
Correct |
348 ms |
636 KB |
Output is correct |
4 |
Correct |
260 ms |
760 KB |
Output is correct |
5 |
Correct |
257 ms |
760 KB |
Output is correct |
6 |
Correct |
194 ms |
632 KB |
Output is correct |
7 |
Correct |
174 ms |
704 KB |
Output is correct |
8 |
Correct |
277 ms |
640 KB |
Output is correct |
9 |
Correct |
250 ms |
624 KB |
Output is correct |
10 |
Correct |
265 ms |
760 KB |
Output is correct |
11 |
Correct |
262 ms |
700 KB |
Output is correct |
12 |
Correct |
306 ms |
632 KB |
Output is correct |
13 |
Correct |
172 ms |
668 KB |
Output is correct |
14 |
Correct |
325 ms |
704 KB |
Output is correct |
15 |
Correct |
169 ms |
632 KB |
Output is correct |
16 |
Correct |
357 ms |
572 KB |
Output is correct |
17 |
Correct |
112 ms |
716 KB |
Output is correct |
18 |
Correct |
281 ms |
676 KB |
Output is correct |
19 |
Correct |
155 ms |
632 KB |
Output is correct |
20 |
Correct |
274 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |