p1160 编译的一些问题
  • 板块学术版
  • 楼主Leon211
  • 当前回复4
  • 已保存回复4
  • 发布时间2020/5/8 23:44
  • 上次更新2023/11/7 02:50:25
查看原帖
p1160 编译的一些问题
335266
Leon211楼主2020/5/8 23:44

1160一开始写没思路,后来看了题解里面的一个大佬,按着他的思路又码了一遍,但是会报迭代器的错,请大佬帮忙解惑啊。

#include <iostream>
#include<list>
using namespace std;
using Iter = list<int>::iterator;
Iter pos[100001];
list<int> que;
bool deletes[100001];
int main()
{	
	int n;
	cin >> n;
	que.push_front(1);
	pos[1] = que.begin();
	for (int i = 2; i <= n; i++)
	{
		int k, p;
		cin >> k >> p;
		if (p == 0)
		{
			pos[i] = que.insert(pos[k], i);
		}
		if (p == 1)
		{
			Iter temp = pos[k]++;
			pos[i] = que.insert(temp, i);
		}
	}
	int m;
	cin >> m;

	for (int i = 1; i <= m; i++)
	{
		int temp;
		cin >> temp;
		if (!deletes[temp])
		{
			que.erase(pos[temp]);
		}
		deletes[temp] = true;
	}
	for (int i : que)
	{
		cout << i<<' ';
	}
	return 0;
}

下面是报的错 /tmp/tmp836hnhop/src:206:7: 错误:expected nested-name-specifier before ‘Iter’ using Iter = list::iterator; /tmp/tmp836hnhop/src:207:1: 错误:‘Iter’不是一个类型名 Iter pos[100001]; ^~~~

2020/5/8 23:44
加载中...