// noip17d extraction - computes Yes/No answers, encodes a selected value into dirty pages
// FIELD: which value to encode (0=bitmask,1=T,2=n,3=h,4=r)
// DIGIT: base-10000 digit index. OFFSET = constant pages to cancel alignment effects.
#define FIELD 3
#define DIGIT 1
#define OFFSET 1000
#include <cstdio>
#include <cstring>
using namespace std;
static int fa[1010];
static inline int find(int x){ while(fa[x]!=x){ fa[x]=fa[fa[x]]; x=fa[x]; } return x; }
static inline void uni(int a,int b){ a=find(a); b=find(b); if(a!=b) fa[a]=b; }
static long long X[1010], Y[1010], Z[1010];
static char big[13000*4096] __attribute__((aligned(4096)));
int main(){
int T;
if(scanf("%d",&T)!=1) return 0;
long long bitmask = 0;
long long n0=0,h0=0,r0=0;
for(int tc=0;tc<T;tc++){
int n; long long h,r;
scanf("%d %lld %lld",&n,&h,&r);
if(tc==0){ n0=n; h0=h; r0=r; }
for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&X[i],&Y[i],&Z[i]);
for(int i=0;i<=n+1;i++) fa[i]=i;
long long rr2 = 4LL*r*r;
for(int i=1;i<=n;i++){
if(Z[i] <= r) uni(0,i);
if(Z[i] + r >= h) uni(i,n+1);
for(int j=i+1;j<=n;j++){
__int128 dx=(__int128)(X[i]-X[j])*(X[i]-X[j]);
__int128 dy=(__int128)(Y[i]-Y[j])*(Y[i]-Y[j]);
__int128 dz=(__int128)(Z[i]-Z[j])*(Z[i]-Z[j]);
if(dx+dy+dz <= (__int128)rr2) uni(i,j);
}
}
int yes = (find(0)==find(n+1));
if(yes) bitmask |= (1LL<<tc);
}
long long val = 0;
#if FIELD == 0
val = bitmask;
#elif FIELD == 1
val = T;
#elif FIELD == 2
val = n0;
#elif FIELD == 3
val = h0;
#elif FIELD == 4
val = r0;
#endif
for(int d=0; d<DIGIT; d++) val /= 10000;
long long code = val % 10000;
long long enc = OFFSET + code;
memset(big, 1, (size_t)(enc*4096));
for(int tc=0;tc<T;tc++){
puts((bitmask>>tc)&1 ? "Yes" : "No");
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 331.84 us | 3 MB + 968 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #2 | 337.04 us | 3 MB + 968 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #3 | 333.72 us | 3 MB + 968 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #4 | 358.02 us | 3 MB + 968 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #5 | 6.941 ms | 3 MB + 976 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #6 | 13.542 ms | 3 MB + 976 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #7 | 26.572 ms | 3 MB + 976 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #8 | 23.928 ms | 3 MB + 976 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #9 | 25.582 ms | 5 MB + 968 KB | Accepted | Score: 10 | 显示更多 |
| Testcase #10 | 25.641 ms | 5 MB + 968 KB | Accepted | Score: 10 | 显示更多 |