# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
72026 |
2018-08-26T04:48:01 Z |
The quick brown fox jumps over the lazy dog(#2200, khsoo01) |
통행이 제한된 저택 (FXCUP3_key) |
C++17 |
|
4 ms |
744 KB |
#include "key.h"
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;
const int N = 1005;
int n, par[N], cyc[N], cs[N], cc;
pii ord[N];
bool vis[N];
vector<int> ci[N];
int dfs (int I) {
if(vis[I]) return 0;
if(cyc[I]) {
for(auto &T : ci[cyc[I]]) {
vis[T] = true;
}
return cs[cyc[I]];
}
else {
vis[I] = true;
return dfs(par[I]) + 1;
}
}
int Try (vector<int> &V) {
fill(vis+1, vis+1+n, false);
int R = 0;
for(auto &T : V) {
R += dfs(T);
}
return R;
}
void EnsureKeyInfo(int _N) {
n = _N;
for(int i=1;i<=n;i++) {
TakeKey(i);
int T = Explore();
ord[i] = {T, i};
}
sort(ord+1, ord+1+n);
for(int i=1;i<=n;i++) {
if(ord[i].X == 1) {
cyc[ord[i].Y] = ++cc;
cs[cc] = 1;
ci[cc].push_back(ord[i].Y);
continue;
}
int S = 0, E = i-1;
bool inc = false;
while(S<E) {
int M = (S+E)/2+1;
vector<int> V;
for(int j=M;j<i;j++) {
V.push_back(ord[j].Y);
TakeKey(ord[j].Y);
}
TakeKey(ord[i].Y);
int A = Try(V), B = Explore();
if(B - A == 0) inc = true;
if(B - A <= 1) S = M;
else E = M-1;
}
if(S == 0) {
cyc[ord[i].Y] = ++cc;
cs[cc] = ord[i].X;
ci[cc].push_back(ord[i].Y);
continue;
}
else if(inc) {
cyc[ord[i].Y] = cyc[ord[S].Y];
ci[cyc[ord[S].Y]].push_back(ord[i].Y);
}
else par[ord[i].Y] = ord[S].Y;
}
for(int i=1;i<=n;i++) {
fill(vis+1, vis+1+n, false);
dfs(i);
for(int j=1;j<=n;j++) {
if(vis[j]) Report(i, j);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
4 ms |
744 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
4 ms |
744 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Runtime error |
4 ms |
744 KB |
Execution failed because the return code was nonzero |
3 |
Halted |
0 ms |
0 KB |
- |