全RE 求调
  • 板块灌水区
  • 楼主a_little_carrot
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/3 19:41
  • 上次更新2024/10/3 21:25:48
查看原帖
全RE 求调
1042960
a_little_carrot楼主2024/10/3 19:41

Link

#include "iostream"
using namespace std ;

struct Node
{
	Node *to,*from ;
	int number,value ;
} ;

int n,k ;
Node book[100005] ;

void init()
{
	book[0].to=&book[1] ;
	for(int i=1;i<=n;++i)
	{
		book[i].to=&book[i+1] ;
		book[i].from=&book[i-1] ;
		book[i].number=book[i].value=i ;
	}
}

Node * find(int number)
{
	Node *u=&book[0] ;
	for(int i=1;i<=number;++i) u=u->to  ;
	return u ;
}

void change(Node *start,Node *end,Node *to)
{
	start->from->to=end->to ;
	end->to->from=start->from ;
	end->to=to->to ;
	to->to->from=end ;
	to->to=start ;
	start->from=to ;
}

int main()
{
	cin>>n>>k ;
	init() ;
	for(int i=1,a,b,c;i<=k;++i)
	{
		cin>>a>>b>>c ;
		change(find(a),find(b),find(c)) ;
	}
	int i=1 ;
	for(Node *u=book[0].to;i<=10;u=u->to,++i)
	{
		cout<<u->number<<endl ;
	}
	return 0 ;
}
2024/10/3 19:41
加载中...