纪念

· · 个人记录

前言

2023年10月14日意义非凡,借此供未来留恋

正文

~~1.这几天在教室的经历,愿友谊长存~~

2.独立自主花两个多小时AC提高一题(奶酪),代码如下

(20pts)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int n,h,r,read(),id;
vector<int> a[1005];
//bool pre[1005],suf[1005];
map<int,int> t;

inline int twice(int value) {return value*value;}

bool bfs(queue<int> q){
    bool vis[n+1];
    memset(vis,1,sizeof(vis));
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(auto v:a[u]){
            if(t.find(v)!=t.end()) return true;
            if(vis[v]) q.push(v);
        }
    }
    return false;
}

void init()
{
    id=0;
    t.clear();
    queue<int> q;
    cin>>n>>h>>r;
    int x[n+1],y[n+1],z[n+1];
    for(int i=1;i<=n;i++) {x[i]=read(); y[i]=read(); z[i]=read();}
    for(int i=1;i<=n;i++)
    {
        int k;
        //pre[i]=(z[i]-r<=0)?1:0;
        if(z[i]-r<=0) q.push(i);
        //suf[i]=(z[i]+r>=h)?1:0;
        if(z[i]+r>=h) t.insert(make_pair(i,++id));
        for(int j=i+1;j<=n;j++)
        {
            k=sqrt(twice(x[i]-x[j])+twice(y[i]-y[j])+twice(z[i]-z[j]));
            if(k<=2*r) a[i].push_back(j);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<i<<" "<<pre[i]<<" "<<suf[i]<<endl;
        for(int j=i+1;j<=n;j++)
        {
            cout<<j<<" "<<dist[i][j]<<endl;
        }
    }*/
    bfs(q)==1?printf("Yes\n"):printf("No\n");
    return;
}

int main()
{
    int T;
    cin>>T;
    for(int i=1;i<=T;i++) init();
    return 0;
}

int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-') f=-1;
        ch=getchar();
        }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
        }
    return x*f;
}

(30pts)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int n,h,r,read(),id;
bool pre[1005],suf[1005];
vector<int> a[1005];
map<int,int> t;
//bool pre[1005],suf[1005];

inline int twice(int value) {return value*value;}

bool bfs(queue<int> q){
    bool vis[n+1];
    memset(vis,1,sizeof(vis));
    while(!q.empty())
    {
        int u=q.front();
        //cout<<q<<endl;
        q.pop();
        vis[u]=false;
        for(auto v:a[u]){
            if(t.find(v)!=t.end()) return true;
            if(vis[v]){
                q.push(v);
                vis[v]=false;
            }
        }
    }
    return false;
}

void init()
{
    //memset(dist,);
    id=0;
    queue<int> q;
    t.clear();
    cin>>n>>h>>r;
    for(int i=1;i<=n;i++) a[i].clear();
    int x[n+1],y[n+1],z[n+1];
    for(int i=1;i<=n;i++) {x[i]=read(); y[i]=read(); z[i]=read();}
    for(int i=1;i<=n;i++)
    {
        int k;
        pre[i]=(z[i]-r<=0)?1:0;
        if((z[i]>0&&(z[i]-r<=0))||(z[i]<0&&(z[i]+r>=0))||z[i]==0) q.push(i);
        suf[i]=(z[i]+r>=h)?1:0;
        if((z[i]>h&&(z[i]-r<=h))||(z[i]<h&&(z[i]+r>=h))||z[i]==h) t.insert(make_pair(i,++id));
        for(int j=i+1;j<=n;j++)
        {
            k=sqrt(twice(x[i]-x[j])+twice(y[i]-y[j])+twice(z[i]-z[j]));
            if(k<=2*r) a[i].push_back(j);
        }
    }
    /*cout<<"组:"<<t.size()<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<i<<" "<<pre[i]<<" "<<suf[i]<<endl;
        //for(int j=i+1;j<=n;j++)
        //
        //  cout<<j<<" "<<dist[i][j]<<endl;
        //
    }
    if(q.empty()==1){
        printf("No\n");
        return;
    }*/
    if(t.size()==0){
        printf("No\n");
        return;
    }
    else if(q.empty()){
        printf("No\n");
        return;
    }
    else if(n==1){
        printf("Yes\n");
        return;
    }
    else bfs(q)==1?printf("Yes\n"):printf("No\n");
    return;
}

int main()
{
    int T;
    cin>>T;
    for(int i=1;i<=T;i++) init();
    return 0;
}

int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-') f=-1;
        ch=getchar();
        }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
        }
    return x*f;
}

(70pts)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int n,h,r,read(),id;
bool pre[1005],suf[1005];
vector<int> a[1005];
map<int,int> t;
//bool pre[1005],suf[1005];

inline int twice(int value) {return value*value;}

bool bfs(queue<int> q){
    bool vis[n+1];
    memset(vis,1,sizeof(vis));
    while(!q.empty())
    {
        int u=q.front();
        //cout<<q<<endl;
        q.pop();
        vis[u]=false;
        for(auto v:a[u]){
            if(t.find(v)!=t.end()) return true;
            if(vis[v]){
                q.push(v);
                vis[v]=false;
            }
        }
    }
    return false;
}

void init()
{
    //memset(dist,);
    id=0;
    queue<int> q;
    t.clear();
    cin>>n>>h>>r;
    for(int i=1;i<=n;i++) a[i].clear();
    int x[n+1],y[n+1],z[n+1];
    for(int i=1;i<=n;i++) {x[i]=read(); y[i]=read(); z[i]=read();}
    for(int i=1;i<=n;i++)
    {
        int k;
        pre[i]=(z[i]-r<=0)?1:0;
        if((z[i]>0&&(z[i]-r<=0))||(z[i]<0&&(z[i]+r>=0))||z[i]==0) q.push(i);
        suf[i]=(z[i]+r>=h)?1:0;
        if((z[i]>h&&(z[i]-r<=h))||(z[i]<h&&(z[i]+r>=h))||z[i]==h) t.insert(make_pair(i,++id));
        for(int j=i+1;j<=n;j++)
        {
            k=sqrt(twice(x[i]-x[j])+twice(y[i]-y[j])+twice(z[i]-z[j]));
            if(k<=2*r) a[i].push_back(j),a[j].push_back(i);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<i<<endl;
        for(auto v:a[i]){
            cout<<v<<" ";
        }
    }

    cout<<"组:"<<t.size()<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<i<<" "<<pre[i]<<" "<<suf[i]<<endl;
        //for(int j=i+1;j<=n;j++)
        //
        //  cout<<j<<" "<<dist[i][j]<<endl;
        //
    }*/
    if(q.empty()==1){
        printf("No\n");
        return;
    }
    if(t.size()==0){
        printf("No\n");
        return;
    }
    else if(q.empty()){
        printf("No\n");
        return;
    }
    else if(n==1){
        printf("Yes\n");
        return;
    }
    else bfs(q)==1?printf("Yes\n"):printf("No\n");
    return;
}

int main()
{
    int T;
    cin>>T;
    for(int i=1;i<=T;i++) init();
    return 0;
}

int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-') f=-1;
        ch=getchar();
        }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
        }
    return x*f;
}

/*
1
8 5581 3224
-5586 -4382 4074
-8416 0 4315
840 -3792 142
-7214 -7830 5162
6112 9150 4125
2400 848 1298
-3604 2463 1637
9476 8708 660

1
8 5823 3257
-1251 -6568 5499
6086 -5625 5058
156 -7512 4019
674 -3988 3393
-1421 999 442
-488 -6533 772
-7714 -7816 2162
-9420 2665 5337*/

(80pts)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int n,h,r,read(),id;
bool pre[1005],suf[1005];
vector<int> a[1005];
map<int,int> t;
//bool pre[1005],suf[1005];

inline int twice(int value) {return value*value;}

bool bfs(queue<int> q){
    bool vis[n+1];
    memset(vis,1,sizeof(vis));
    while(!q.empty())
    {
        int u=q.front();
        //cout<<q<<endl;
        q.pop();
        vis[u]=false;
        for(auto v:a[u]){
            if(t.find(v)!=t.end()) return true;
            if(vis[v]){
                q.push(v);
                vis[v]=false;
            }
        }
    }
    return false;
}

void init()
{
    //memset(dist,);
    id=0;
    queue<int> q;
    t.clear();
    cin>>n>>h>>r;
    double R=r;
    for(int i=1;i<=n;i++) a[i].clear();
    int x[n+1],y[n+1],z[n+1];
    for(int i=1;i<=n;i++) {x[i]=read(); y[i]=read(); z[i]=read();}
    for(int i=1;i<=n;i++)
    {
        double k;
        pre[i]=(z[i]-r<=0)?1:0;
        if((z[i]>0&&(z[i]-r<=0))||(z[i]<0&&(z[i]+r>=0))||z[i]==0) q.push(i);
        suf[i]=(z[i]+r>=h)?1:0;
        if((z[i]>h&&(z[i]-r<=h))||(z[i]<h&&(z[i]+r>=h))||z[i]==h) t.insert(make_pair(i,++id));
        for(int j=i+1;j<=n;j++)
        {
            k=sqrt(twice(x[i]-x[j])+twice(y[i]-y[j])+twice(z[i]-z[j]));
            if(k<=2.0*R) a[i].push_back(j),a[j].push_back(i);
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        cout<<i<<endl;
        for(auto v:a[i]){
            cout<<v<<" ";
        }
    }

    cout<<"组:"<<t.size()<<endl;
    for(int i=1;i<=n;i++)
    {
        cout<<i<<" "<<pre[i]<<" "<<suf[i]<<endl;
        //for(int j=i+1;j<=n;j++)
        //
        //  cout<<j<<" "<<dist[i][j]<<endl;
        //
    }*/
    if(q.empty()==1){
        printf("No\n");
        return;
    }
    if(t.size()==0){
        printf("No\n");
        return;
    }
    else if(q.empty()){
        printf("No\n");
        return;
    }
    else if(n==1){
        printf("Yes\n");
        return;
    }
    else bfs(q)==1?printf("Yes\n"):printf("No\n");
    return;
}

int main()
{
    int T;
    cin>>T;
    for(int i=1;i<=T;i++) init();
    return 0;
}

int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-') f=-1;
        ch=getchar();
        }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
        }
    return x*f;
}

/*
1
2 5202 1301
0 0 1301
102 1 3901*/

(100pts)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int n,h,r,id;
bool pre[1005],suf[1005];
vector<int> a[1005];
map<int,int> t;

inline long double twice(long double value) {return value*value;}

bool bfs(queue<int> q){
    bool vis[n+1];
    memset(vis,1,sizeof(vis));
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(auto v:a[u]){
            if(t.find(v)!=t.end()) return true;
            if(vis[v]){
                q.push(v);
                vis[v]=false;
            }
        }
    }
    return false;
}

void init()
{
    id=0;
    queue<int> q;
    t.clear();
    cin>>n>>h>>r;
    double R=r;
    for(int i=1;i<=n;i++) a[i].clear();
    long double x[n+1],y[n+1],z[n+1];
    for(int i=1;i<=n;i++) {scanf("%Lf%Lf%Lf",&x[i],&y[i],&z[i]);}
    for(int i=1;i<=n;i++)
    {
        long double k;
        if((z[i]>0&&(z[i]-r<=0))||(z[i]<0&&(z[i]+r>=0))||z[i]==0) q.push(i);
        if((z[i]>h&&(z[i]-r<=h))||(z[i]<h&&(z[i]+r>=h))||z[i]==h) t.insert(make_pair(i,++id));
        for(int j=i+1;j<=n;j++)
        {
            k=sqrt(twice(x[i]-x[j])+twice(y[i]-y[j])+twice(z[i]-z[j]));
            if(k<=2.0*R) a[i].push_back(j),a[j].push_back(i);
        }
    }
    if(t.size()==0){
        printf("No\n");
        return;
    }
    else if(q.empty()){
        printf("No\n");
        return;
    }
    else if(n==1){
        printf("Yes\n");
        return;
    }
    else bfs(q)==1?printf("Yes\n"):printf("No\n");
    return;
}

int main()
{
    int T;
    cin>>T;
    for(int i=1;i<=T;i++) init();
    return 0;
}