QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298012#4632. Card Sharkdefyers#Compile Error//C++172.7kb2024-01-05 15:47:062024-01-05 15:47:06

Judging History

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

  • [2024-01-05 15:47:06]
  • 评测
  • [2024-01-05 15:47:06]
  • 提交

answer

#include "bits/stdc++.h"

#pragma GCC optimize("Ofast")
#pragma GCC targetr("avx2")

using namespace std;

using ll = long long;
using pii = pair<int, int>;

using vi = vector<int>;
#define sz(x) (int)(x.size())
#define all(x) (x).begin(), (x).end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)

struct SuffixArray {
	vi sa, lcp;
	SuffixArray(string &s, int lim = 256) {
		int n = sz(s) + 1, k = 0, a, b;
		vi x(all(s) + 1), y(n), ws(max(n, lim)), rank(n);
		sa = lcp = y, iota(all(sa), 0);
		for (int j = 0, p = 0; p < n; j = max(1, j * 2), lim = p) {
			p = j, iota(all(y),  n - j);
			rep(i,0,n) if (sa[i] >= j) y[p++] = sa[i] - j;
			fill(all(ws), 0);
			rep(i,0,n) ws[x[i]]++;
			rep(i,1,lim) ws[i] += ws[i - 1];
			for (int i = n; i--;) sa[--ws[x[y[i]]]] = y[i];
			swap(x, y), p = 1, x[sa[0]] = 0;
			rep(i, 1, n) a = sa[i - 1], b = sa[i], x[b] = 
				(y[a] == y[b] && y[a + j] == y[b + j]) ? p - 1: p++;			
		}
		rep(i, 1, n) rank[sa[i]] = i;
		for (int i = 0, j; i < n - 1; lcp[rank[i++]] = k)
			for (k && k--, j = sa[rank[i] - 1];
				s[i + k] == s[j + k]; k++);
	}
};

struct DSU {
	int n;
	vector<int> dsu;
	vector<int> mn, mx;
	DSU(int _n) {
		n = _n;
		dsu.resize(n);
		mn.resize(n), mx.resize(n);
		iota(dsu.begin(), dsu.end(), 0);
		iota(mn.begin(), mn.end(), 0);
		iota(mx.begin(), mx.end(), 0);

	}

	int find(int x) {
		if (dsu[x]) return x;
		else return dsu[x] = find(dsu[x]);
	}

	void uni(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;

		dsu[y] = x;
		mx[x] = max(mx[x], mx[y]);
		mn[x] = min(mn[x], mn[y]);
	}
};

const int MAXN = 500005;

void solve(int TC) {
	string s;
	cin >> s;

	SuffixArray SA(s);
	int n = s.size();

	DSU dsu(n + 1);

	struct Node {
		int L, R;
		int mnlen, mxlen;
	};

	vector<vector<int>> g;
	vector<Node> nde;

	vector<int> nodepnt(n + 1, -1);	
	vector<vector<int>> merge(MAXN);

	for (int i = 1; i <= n; i++) {
		cout << "SA: " << SA.sa[i] << " lcp: " << SA.lcp[i] << endl;
		if (i > 1) {
			merge[SA.lcp[i]].push_back(i);
		}

		int len = n - SA.sa[i];
		nodepnt[i] = nde.size();
		nde.push_back({i, i, len + 1, len + 1});
		g.push_back({});
	}

	for (int i = MAXN - 1; i >= 0; i--) {
		int sz = (int)merge[i].size();
		for (int j = 0; j < sz; j++) {
			int x = merge[i][j];
			int k = j;
			while (merge)
		}
	}

	for (int i = 0; i < n - 1; i++) {
		auto [mergetime, x] = merge_t[i];

		int X = dsu.find(x);
		int Y = dsu.find(x - 1);

		dsu.uni(X, Y);
	}

}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

Details

answer.code: In function ‘void solve(int)’:
answer.code:109:32: error: could not convert ‘merge’ from ‘std::vector<std::vector<int> >’ to ‘bool’
  109 |                         while (merge)
      |                                ^~~~~
      |                                |
      |                                std::vector<std::vector<int> >
answer.code:110:17: error: expected primary-expression before ‘}’ token
  110 |                 }
      |                 ^
answer.code:114:39: error: ‘merge_t’ was not declared in this scope; did you mean ‘merge’?
  114 |                 auto [mergetime, x] = merge_t[i];
      |                                       ^~~~~~~
      |                                       merge