计蒜客 关系查询 map
题目:/*** From:* Qingdao Agricultural University* Created by XiangwangAcmer* Date : 2019-10-02-11.57.31* Talk is cheap.Show me your code.*/#include<iostream>#include<cstring>#inc...
·
题目:
/**
* From:
* Qingdao Agricultural University
* Created by XiangwangAcmer
* Date : 2019-10-02-11.57.31
* Talk is cheap.Show me your code.
*/
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<string>
#include<cstdlib>
#define ll long long
using namespace std;
const ll maxn = 1e6 + 5;
const ll minn = 1e9 + 5;
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LIMIT = 4294967295LL;
vector<int>v[maxn];
int dp[maxn];
int G[500][500];
bool row[maxn], col[maxn];
bool flag = 0;
queue<int>q;
map<string,int>dict;
int ids;
int find(string a) {
if(dict.count(a)==0)
dict [a] = ++ids;
else return
dict[a];
}
int main() {
ios::sync_with_stdio(false);
int n;
ids = 0;
cin >> n;
string a,b;
for(int i = 0; i < n; i++) {
cin>>a>>b;
int x = find(a), y = find(b);
G[x][y] = G[y][x] = 1;
}
int m;
cin>>m;
while(m--){
cin>>a>>b;
if(G[find(a)][find(b)])
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)