#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
const int N=1e5+7;
int head[N];
int cnt;
struct node
{
int next;//前一個節點
int to;//這條邊的終點
}edge[N<<1];
void add(int u,int v)
{
edge[cnt].to=v;
edge[cnt].next=head[u];
head[u]=cnt++;
}
int main()
{
cnt=0;
int n;
cin>>n;
for(int i=0;i<n;i++)
head[i]=-1; //初始化 -1 表示當前邊爲最開始的邊,之前沒有邊
//遍歷以p爲起點的所有邊
int p;
cin>>p;
for(int i=head[p];i!=-1;i=edge[i].next)
{
//對於程序來說是指向下一條邊,但是對於輸入來說,是指向前一條邊
}
}
//edge[cnt].to=a edge[cnt].next=b head[p]=cnt
//表示 路徑 p 到 a 即 edge[head[p]].to=a;
//k的前一個與之相連的點(按照輸入順序)是 b
鏈式前向星
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.