XJTUPC2023同步赛 题解
所有题面
A. 大水题
纯签
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
int n;
cin>>n;
if(n<=6)
cout<<"water"<<'\n';
else
cout<<"dry"<<'\n';
return 0;
}B. 原粥率
纯签
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
double a,b;
cin>>a>>b;
cout<<a/b<<'\n';
return 0;
}C. 话剧
算个概率
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
double x,y,z;
scanf("%lf %lf %lf",&x,&y,&z);
printf("%.6lf\n",z/x/y);
return 0;
}D. 点集扩张
发现需要是一个包含原点的矩形,判断一下就行
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<pair<int,int>>A,B;
int main() {
ios::sync_with_stdio(false);
int n;
cin>>n;
int x_min=1e9,x_max=-1e9,y_min=1e9,y_max=-1e9;
for(int i=1;i<=n;i++)
{
int x,y;
cin>>x>>y;
x_min=min(x_min,x);
x_max=max(x,x_max);
y_min=min(y,y_min);
y_max=max(y,y_max);
B.insert({x,y});
}
if((y_max-y_min+1)*(x_max-x_min+1)!=B.size())
cout<<-1<<'\n';
else if(x_min>0||x_max<0||y_min>0||y_max<0)
cout<<-1<<'\n';
else
{
bool flag=false;
for(int i=x_min;i<=x_max;i++)
{
for(int j=y_min;j<=y_max;j++)
{
if(B.count({i,j})==0)
{
flag=true;
break;
}
}
}
if(flag)
cout<<-1<<'\n';
else
cout<<x_max-x_min+y_max-y_min<<'\n';
}
return 0;
}E. 全错
先把图建起来,然后看是否是题目的条件
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=205;
int v[N];
bool vis[N];
void init(int n)
{
memset(vis,false,sizeof(vis));
for(int i=1;i<=n;i++)
v[i]=i;
}
bool isExist(vector<int> q,int x)
{
for(auto it:q)
if(it==x)
return true;
return false;
}
int dfs(int x)
{
if(vis[x])
return 0;
int temp=x;
while(v[x]!=x)
{
vis[x]=true;
if(v[x]==temp)
return 0;
else if(vis[v[x]])
return 1;
x=v[x];
}
return 1;
}
int main() {
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
int n;
double b;
cin>>n>>b;
init(n);
for(int i=1;i<=n;i++)
{
double _max=-10;
int cur=-1;
double x;
for(int j=1;j<=n;j++)
{
cin>>x;
if(j==i)
continue;
if(x>=b&&x>_max)
{
_max=x;
cur=j;
}
}
if(cur!=-1)
v[i]=cur;
}
if(n==1)
{
cout<<"kono jinsei, imi ga nai!"<<'\n';
continue;
}
bool flag=false;
for(int i=1;i<=n;i++)
{
int F=dfs(i);
if(F==1)
flag=true;
}
for(int i=1;i<=n;i++)
{
if(!vis[i])
{
flag=true;
break;
}
}
if(flag)
cout<<"hbxql"<<'\n';
else
cout<<"wish you the best in your search"<<'\n';
}
return 0;
}