QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575988#6785. What Kind of Friends Are You?icedAC ✓297ms3920kbC++231.7kb2024-09-19 17:46:012024-09-19 17:46:03

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 17:46:03]
  • 评测
  • 测评结果:AC
  • 用时:297ms
  • 内存:3920kb
  • [2024-09-19 17:46:01]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<bitset>
#include<iomanip>
#include<tuple>
#include<numeric>



#define ll long long
#define inf 0x3f3f3f3f
#define lc p<<1
#define rc p<<1|1
#define endl '\n'
#define all(a) a.begin()+1,a.end()
#define all0(a) a.begin(),a.end()
#define lowbit(a) (a&-a)
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

using namespace std;
const double eps=1e-6;
typedef pair<int,int>PII;

void solve()
{
	int n,q;
	cin>>n>>q;
	vector<vector<int>>f(n+1,vector<int>(q+1));
	vector<string>g[q+1];
	set<string>op;
	int m;cin>>m;
	for(int i=1;i<=m;i++)
	{
		string s;cin>>s;
		op.insert(s);
	}
	set<string>s2;
	for(int i=1;i<=q;i++)
	{
		int x;cin>>x;
		while(x--)
		{
			string s;cin>>s;
			g[i].pb(s);
			s2.insert	(s);
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		map<string,int>mp;
		set<string>s;
		int cnt=0;
		for(int j=1;j<=q;j++)
		{
			cin>>f[i][j];
			if(f[i][j]==1)
			{
				cnt++;
				for(auto t:g[j]) mp[t]++;
			}
			else
			{
				for(auto t:g[j]) mp[t]=-1e9;
			}
			
		}
		for(auto [x,y]:mp)
		{
			if(y==cnt) s.insert(x);
		}
		if(cnt==0 && op.size()-s2.size()==1)
		{
			
			for(auto t:op)
			{
				//cout<<t<<endl;
				if(!s2.count(t)) {cout<<t<<endl;break;}
			}
		}
		else if(s.size()==1) {cout<<*s.begin()<<endl;}
		else cout<<"Let's go to the library!!"<<endl;
	}
	
	
}
	
	
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--)
	solve();
	
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3824kb

input:

2
3 4
5 Serval Raccoon Fennec Alpaca Moose
4 Serval Raccoon Alpaca Moose
1 Serval
1 Fennec
1 Serval
1 1 0 1
0 0 0 0
1 0 0 0
5 5
11 A B C D E F G H I J K
3 A B K
4 A B D E
5 A B K D E
10 A B K D E F G H I J
4 B D E K
0 0 1 1 1
1 0 1 0 1
1 1 1 1 1
0 0 1 0 1
1 0 1 1 1

output:

Serval
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
B
Let's go to the library!!
K

result:

ok 8 lines

Test #2:

score: 0
Accepted
time: 297ms
memory: 3920kb

input:

100
98 16
154 rliLiumEVQKkJNnMjAj qnhiLgzjsjRsu eiHrssJvVWBLaRFMQVo TwLVZsRNyEOysXY JtYpguJiCihuObMygLVt YiquXjVeDoe pSkLcJbceYhjx vrVgRvYziqmEpVJdB OYLIFEnoKsDXLtEpyRIF EKTKIOpwEswTWgvihdCa MCCudkhYJC wOkSGOgjZlWgf hTcqiMZqeBCjOmzAt dPWGKzHa iDWjhWBQsoQCInigoNIf qGXWZvcWVJvGUbZ oRLdhU NecdjCwFAikYe...

output:

Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
Let's go to the library!!
FJVBxEemjhzUqZxTjU
Let's go to the library!!
Let's go to the libra...

result:

ok 9542 lines