Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1090PATbasic部分正确 #14

Closed
WaterLemonade opened this issue Jan 26, 2019 · 1 comment
Closed

1090PATbasic部分正确 #14

WaterLemonade opened this issue Jan 26, 2019 · 1 comment
Labels

Comments

@WaterLemonade
Copy link

WaterLemonade commented Jan 26, 2019

#include <bits/stdc++.h>
using namespace std;
map<int,vector<int> >mp;
map<int,bool>shown;
bool isvalid(vector <int> box){
	for(int i=0;i<box.size();i++){
		for(int j=0;i<mp[box[i]].size();j++)
			if(shown[mp[box[i]][j]])return false;
	}return true;
}
int main(int argc, char **argv)
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	for(int i=0;i<m;i++){
		
		int t;
		cin>>t;
		vector<int > box;
		shown.clear();//
		while(t--){
			int b;
			cin>>b;
			box.push_back(b);
			shown[b]=true;
		}
		if(isvalid(box))printf("Yes\n");
		else printf("No\n");
		
	}
	
	
	return 0;
}
@xlucn
Copy link
Owner

xlucn commented Jan 26, 2019

不好意思,我对c++的map等标准库函数不很熟悉,不能确定你的代码在哪里有问题。
另外,不知道这里是误改还是什么:

		for(int j=0;i<mp[box[i]].size();j++)

循环控制应该是对j的判断吧。

@xlucn xlucn added the question label Apr 20, 2020
@xlucn xlucn closed this as completed Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants