天梯赛 - L2-002 链表去重
阅读原文时间:2023年07月10日阅读:1

GG思密达,第二个测试点的三分怎么也拿不上,我还是比较熟悉指针,用指针来写~,写完去上概率论

题目链接:https://www.patest.cn/contests/gplt/L2-002

#include
#include
#include
#include
using namespace std;
const int maxn = 1e5+;
struct _NODE_
{
int addr;
int key;
int abskey;
int Next;
_NODE_ *NextNode;
};
_NODE_ node[maxn];
int vis[maxn];
bool cmp(_NODE_ A,_NODE_ B)
{
return A.addrNextNode!=NULL)
{
v1 = v1->NextNode;
if(v1->NextNode==NULL)
{
printf("%05d %d %d\n",v1->addr,v1->key,v1->Next);
}
else
{
printf("%05d %d %05d\n",v1->addr,v1->key,v1->Next);
}
}
}
int main()
{
int HeadAddr,n;
scanf("%d %d",&HeadAddr,&n);
for(int i=;iNextNode = NULL;
Head2 = Travel2 = new _NODE_;
Head2->NextNode = NULL;
while(tt--)
{
int l = ;
int r = n-;
while(l<=r) { int mid = (l+r)/; if(node[mid].addrNextAddr)
{
r = mid;
}
else
{
if(vis[node[mid].abskey])
{
Travel2->Next = node[mid].addr;
Travel2->NextNode = &node[mid];
Travel2 = Travel2->NextNode;
NextAddr = node[mid].Next;
}
else
{
Travel1->Next = node[mid].addr;
vis[node[mid].abskey] = ;
Travel1->NextNode = &node[mid];
Travel1 = Travel1->NextNode;
NextAddr = node[mid].Next;
}
break;
}
}
}
Travel1->Next = -;
Travel2->Next = -;
Print(Head1);
Print(Head2);
return ;
}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器