我一直在使用 STL,但今天我遇到了这个错误:
error: no class template named 'rebind' in 'class std::vector<int, std::allocator> >'
在以下程序中:
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bitset>
#include <climits>
#include <stack>
#include <cctype>
#include <sstream>
using namespace std;
vector<int, vector<int> > G[2000005];
vector<int, vector<int> > Grev[2000005];
int f[2000005], order[2000005], leader[2000005], t = 0, parent = 0;
bool explored[2000005];
void dfs_reverse(int i) {
explored[i] = true;
for(vi::iterator it=G[i].begin(); it != G[i].end(); it++)
if(!explored[*it])
dfs_reverse(*it);
t++;
f[i] = t;
}
void dfs(int i) {
explored[i] = true;
leader[i] = parent;
for(vi::iterator it=G[i].begin(); it != G[i].end(); it++)
if(!explored[*it])
dfs(*it);
}
int main() {
int N, i, j, u, v;
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
scanf("%d", &N);
for(i=0; i<N; i++) {
scanf("%d %d", &u, &v);
if(u > 0) {
if(v > 0) {
G[N + u].push_back(v); G[N + v].push_back(u);
Grev[v].push_back(N + u); Grev[u].push_back(N + v);
} else {
G[N + u].push_back(N - v); G[-v].push_back(u);
Grev[N-v].push_back(N+u); Grev[u].push_back(-v);
}
} else {
if(v > 0) {
G[-u].push_back(v); G[N + v].push_back(N - u);
Grev[v].push_back(-u); Grev[N-u].push_back(N+v);
} else {
G[u].push_back(N - v); G[-v].push_back(N - u);
Grev[N-v].push_back(u); Grev[N-u].push_back(-v);
}
}
}
memset(explored, false, 2000005*sizeof(bool));
for(i=2*N; i>0; i--) {
if(!explored[i])
dfs_reverse(i);
order[f[i]] = i;
}
memset(explored, false, 2000005*sizeof(bool));
for(i=2*N; i>0; i--) {
if(!explored[order[i]]) {
parent = order[i];
dfs(order[i]);
}
}
for(i=1; i<=N; i++)
if(leader[i] == leader[N+i])
break;
if(i <= N)
printf("Unsatisfiable\n");
else printf("Satisfiable\n");
return 0;
}
我正在尝试使用 Kosaraju 的两遍算法来解决 2SAT 问题,以查找强连接组件。基本上,我必须为一个大图(2000000 个节点)分配内存。我正在使用 vector > G[2000005] 执行此操作,但它给了我上述错误。如何解决此错误?