全re球条
查看原帖
全re球条
1781740
szxs300NFf楼主2025/7/1 10:50

在本地和评测机上都re,但是本人没看出来哪里会re
(有输出,两个空行)

#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int, int> pr;
typedef vector<int> graph;
typedef vector<pr> wgraph;
typedef priority_queue<pr, wgraph, greater<pr> > PQ;
const int MAXN = 1e3 + 5, MAXM = 1e4 + 5;
const LL mod = 1593923917, base = 25;
vector<LL> tx[MAXN];
graph ans[MAXM];
int n, m;
LL hashe(string &s) {
	LL t = 0;
	for (auto v : s) {
		t *= base;
		t %= mod;
		t += (int) v;
		t %= mod;
	}
	return t;
}
bool bis(vector<LL> &V, LL x) {
	int len = V.size();
	int l = 0, r = len - 1, mid;
	while (l <= r) {
		mid = (l + r) >> 1;
		if (V[mid] == x)	return true;
		if (V[mid] > x)	r = mid - 1;
		else	l = mid + 1;
	}
	return false;
}
int main() {
	freopen("input.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int t;
		cin >> t;
		while (t--) {
			string str;
			cin >> str;
			tx[i].push_back(hashe(str));
		}
		sort(tx[i].begin(), tx[i].end());
	}
	cin >> m;
	for (int i = 1; i <= m; ++i) {
		string t;
		cin >> t;
		LL x = hashe(t);
		for (int j = 1; j <= n; ++j)
			if (!bis(tx[i], x))
				ans[i].push_back(j);
	}
	for (int i = 1; i <= m; ++i) {
		int sz = ans[i].size();
		for (int j = 0; j < sz; ++i) {
			cout << ans[i][j];
			if (sz - j > 1)	cout << ' ';
		}
		cout << endl;
	}
	return 0;
}
2025/7/1 10:50
加载中...