社区讨论
蒟蒻求助,悬赏关注
P11280「GFOI Round 2」Jom & Terry参与者 2已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @m3wbzvil
- 此快照首次捕获于
- 2024/11/25 09:10 去年
- 此快照最后确认于
- 2025/11/04 13:58 4 个月前
凭感觉打的求路径
Dij和dfs都忘了
40 分,Substack4全 WA。
CPP#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<ctime>
#include<stack>
#define N 1000006
#define int long long
int n,m,r;
int ste[N];
using namespace std;
int re()
{
int x=0,p=1;
char y=getchar();
for(;y>'9'||y<'0';y=getchar())
if(y=='-')
p=-p;
for(;y>='0'&&y<='9';y=getchar())
x=x*10+y-'0';
return x*p;
}
vector<int>q[N];
void wr(int x)
{
if(x<0)
x=-x,putchar('-');
if(x>9)
wr(x/10);
putchar(x%10+'0');
}
void dfs(int x)
{
if(!q[x].size())
return;
while(q[x].size())
{
int nex=q[x].back();
q[x].pop_back();
if(ste[nex]>ste[x]+1)
ste[nex]=ste[x]+1;
dfs(nex);
}
}
signed main()
{
printf("I'm here!\n");
n=re(),m=re(),r=re();
for(int i=1;i<=n;i++)
ste[i]=1000006;
ste[r]=0;
for(int i=1;i<=m;i++)
{
int u=re(),v=re();
q[u].push_back(v);
q[v].push_back(u);
}
dfs(r);
int p=re();
while(p--)
{
int a=re(),b=re();
if(ste[a]==1000006)
printf("Jom\n");
else if(ste[a]<=ste[b])
printf("Terry\n");
else
printf("Jom\n");
}
return 0;
}
//9087201950435737471
回复
共 4 条回复,欢迎继续交流。
正在加载回复...